code
stringlengths 3
1.05M
| repo_name
stringlengths 4
116
| path
stringlengths 3
942
| language
stringclasses 30
values | license
stringclasses 15
values | size
int32 3
1.05M
|
---|---|---|---|---|---|
void main()
{
if(aaaa)
{
it = std::find_if(
bbbb.begin(),
bbbb.end(),
[&cccc](const auto& dddd)
{
return (eeee.ffff == iiii && !jjjj.kkkk);
}
);
}
}
namespace ns1 {
void one()
{
if(aaaa)
{
it = std::find_if(
bbbb.begin(),
bbbb.end(),
[&cccc](const auto& dddd)
{
return (eeee.ffff == iiii && !jjjj.kkkk);
}
);
}
}
namespace ns2 {
namespace ns3 {
const auto lamb = []() -> int
{
return 42;
};
void two()
{
if(aaaa)
{
it = std::find_if(
bbbb.begin(),
bbbb.end(),
[&cccc](const auto& dddd)
{
return (eeee.ffff == iiii && !jjjj.kkkk);
}
);
}
}
}
}
}
|
uncrustify/uncrustify
|
tests/input/cpp/Issue_3428.cpp
|
C++
|
gpl-2.0
| 782 |
/***************************************************************************************
*cr
*cr Copyright (c) 2004, The Regents of the
*cr University of California, through Lawrence Berkeley National Laboratory,
*cr Univ. of Calif. at Davis, and Lawrence Livermore National Laboratory
*cr (subject to receipt of any required approvals from U.S. Dept. of Energy).
*cr All rights reserved.
*cr
*cr Please see the accompanying LICENSE file for further information.
*cr
***************************************************************************************/
/***********************************************************************
GLMaterial - Class to encapsulate OpenGL material properties.
***********************************************************************/
#include "GLMaterial.h"
/***************************
Methods of class GLMaterial:
***************************/
GLMaterial::GLMaterial(void)
:ambient(0.2f,0.2f,0.2f,1.0f),
diffuse(0.8f,0.8f,0.8f,1.0f),
specular(0.0f,0.0f,0.0f,1.0f),
shininess(0.0f),
emission(0.0f,0.0f,0.0f,1.0f)
{
}
GLMaterial::GLMaterial(const GLMaterial::Color& sAmbientDiffuse)
:ambient(sAmbientDiffuse),
diffuse(sAmbientDiffuse),
specular(0.0f,0.0f,0.0f,1.0f),
shininess(0.0f),
emission(0.0f,0.0f,0.0f,1.0f)
{
}
GLMaterial::GLMaterial(const GLMaterial::Color& sAmbientDiffuse,const GLMaterial::Color& sSpecular,GLfloat sShininess)
:ambient(sAmbientDiffuse),
diffuse(sAmbientDiffuse),
specular(sSpecular),
shininess(sShininess),
emission(0.0f,0.0f,0.0f,1.0f)
{
}
GLMaterial::GLMaterial(const GLMaterial::Color& sAmbient,const GLMaterial::Color& sDiffuse,const GLMaterial::Color& sSpecular,GLfloat sShininess)
:ambient(sAmbient),
diffuse(sDiffuse),
specular(sSpecular),
shininess(sShininess),
emission(0.0f,0.0f,0.0f,1.0f)
{
}
GLMaterial::GLMaterial(const GLMaterial::Color& sAmbientDiffuse,const GLMaterial::Color& sSpecular,GLfloat sShininess,const GLMaterial::Color& sEmission)
:ambient(sAmbientDiffuse),
diffuse(sAmbientDiffuse),
specular(sSpecular),
shininess(sShininess),
emission(sEmission)
{
}
GLMaterial::GLMaterial(const GLMaterial::Color& sAmbient,const GLMaterial::Color& sDiffuse,const GLMaterial::Color& sSpecular,GLfloat sShininess,const GLMaterial::Color& sEmission)
:ambient(sAmbient),
diffuse(sDiffuse),
specular(sSpecular),
shininess(sShininess),
emission(sEmission)
{
}
void glMaterial(GLenum face,const GLMaterial& material)
{
glMaterial(face,GL_AMBIENT,material.ambient);
glMaterial(face,GL_DIFFUSE,material.diffuse);
glMaterial(face,GL_SPECULAR,material.specular);
glMaterialf(face,GL_SHININESS,material.shininess);
glMaterial(face,GL_EMISSION,material.emission);
}
|
wheath/protein-shop
|
src/GLMaterial.cpp
|
C++
|
gpl-2.0
| 2,822 |
/*
* xen/arch/arm/traps.c
*
* ARM Trap handlers
*
* Copyright (c) 2011 Citrix Systems.
*
* 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.
*/
#include <xen/config.h>
#include <xen/stdbool.h>
#include <xen/init.h>
#include <xen/string.h>
#include <xen/version.h>
#include <xen/smp.h>
#include <xen/symbols.h>
#include <xen/irq.h>
#include <xen/lib.h>
#include <xen/mm.h>
#include <xen/errno.h>
#include <xen/hypercall.h>
#include <xen/softirq.h>
#include <xen/domain_page.h>
#include <public/sched.h>
#include <public/xen.h>
#include <asm/debugger.h>
#include <asm/event.h>
#include <asm/regs.h>
#include <asm/cpregs.h>
#include <asm/psci.h>
#include <asm/mmio.h>
#include <asm/cpufeature.h>
#include "decode.h"
#include "vtimer.h"
#include <asm/gic.h>
#include <asm/vgic.h>
/* The base of the stack must always be double-word aligned, which means
* that both the kernel half of struct cpu_user_regs (which is pushed in
* entry.S) and struct cpu_info (which lives at the bottom of a Xen
* stack) must be doubleword-aligned in size. */
static inline void check_stack_alignment_constraints(void) {
#ifdef CONFIG_ARM_64
BUILD_BUG_ON((sizeof (struct cpu_user_regs)) & 0xf);
BUILD_BUG_ON((offsetof(struct cpu_user_regs, spsr_el1)) & 0xf);
BUILD_BUG_ON((offsetof(struct cpu_user_regs, lr)) & 0xf);
BUILD_BUG_ON((sizeof (struct cpu_info)) & 0xf);
#else
BUILD_BUG_ON((sizeof (struct cpu_user_regs)) & 0x7);
BUILD_BUG_ON((offsetof(struct cpu_user_regs, sp_usr)) & 0x7);
BUILD_BUG_ON((sizeof (struct cpu_info)) & 0x7);
#endif
}
#ifdef CONFIG_ARM_32
static int debug_stack_lines = 20;
#define stack_words_per_line 8
#else
static int debug_stack_lines = 40;
#define stack_words_per_line 4
#endif
integer_param("debug_stack_lines", debug_stack_lines);
void __cpuinit init_traps(void)
{
/* Setup Hyp vector base */
WRITE_SYSREG((vaddr_t)hyp_traps_vector, VBAR_EL2);
/* Trap Debug and Performance Monitor accesses */
WRITE_SYSREG(HDCR_TDRA|HDCR_TDOSA|HDCR_TDA|HDCR_TPM|HDCR_TPMCR,
MDCR_EL2);
/* Trap CP15 c15 used for implementation defined registers */
WRITE_SYSREG(HSTR_T(15), HSTR_EL2);
/* Trap all coprocessor registers (0-13) except cp10 and cp11 for VFP
* /!\ All processors except cp10 and cp11 cannot be used in Xen
*/
WRITE_SYSREG((HCPTR_CP_MASK & ~(HCPTR_CP(10) | HCPTR_CP(11))) | HCPTR_TTA,
CPTR_EL2);
/* Setup hypervisor traps */
WRITE_SYSREG(HCR_PTW|HCR_BSU_INNER|HCR_AMO|HCR_IMO|HCR_FMO|HCR_VM|
HCR_TWE|HCR_TWI|HCR_TSC|HCR_TAC|HCR_SWIO|HCR_TIDCP, HCR_EL2);
isb();
}
asmlinkage void __div0(void)
{
printk("Division by zero in hypervisor.\n");
BUG();
}
/* XXX could/should be common code */
static void print_xen_info(void)
{
char taint_str[TAINT_STRING_MAX_LEN];
printk("----[ Xen-%d.%d%s %s debug=%c %s ]----\n",
xen_major_version(), xen_minor_version(), xen_extra_version(),
#ifdef CONFIG_ARM_32
"arm32",
#else
"arm64",
#endif
debug_build() ? 'y' : 'n', print_tainted(taint_str));
}
register_t *select_user_reg(struct cpu_user_regs *regs, int reg)
{
BUG_ON( !guest_mode(regs) );
#ifdef CONFIG_ARM_32
/*
* We rely heavily on the layout of cpu_user_regs to avoid having
* to handle all of the registers individually. Use BUILD_BUG_ON to
* ensure that things which expect are contiguous actually are.
*/
#define REGOFFS(R) offsetof(struct cpu_user_regs, R)
switch ( reg ) {
case 0 ... 7: /* Unbanked registers */
BUILD_BUG_ON(REGOFFS(r0) + 7*sizeof(register_t) != REGOFFS(r7));
return ®s->r0 + reg;
case 8 ... 12: /* Register banked in FIQ mode */
BUILD_BUG_ON(REGOFFS(r8_fiq) + 4*sizeof(register_t) != REGOFFS(r12_fiq));
if ( fiq_mode(regs) )
return ®s->r8_fiq + reg - 8;
else
return ®s->r8 + reg - 8;
case 13 ... 14: /* Banked SP + LR registers */
BUILD_BUG_ON(REGOFFS(sp_fiq) + 1*sizeof(register_t) != REGOFFS(lr_fiq));
BUILD_BUG_ON(REGOFFS(sp_irq) + 1*sizeof(register_t) != REGOFFS(lr_irq));
BUILD_BUG_ON(REGOFFS(sp_svc) + 1*sizeof(register_t) != REGOFFS(lr_svc));
BUILD_BUG_ON(REGOFFS(sp_abt) + 1*sizeof(register_t) != REGOFFS(lr_abt));
BUILD_BUG_ON(REGOFFS(sp_und) + 1*sizeof(register_t) != REGOFFS(lr_und));
switch ( regs->cpsr & PSR_MODE_MASK )
{
case PSR_MODE_USR:
case PSR_MODE_SYS: /* Sys regs are the usr regs */
if ( reg == 13 )
return ®s->sp_usr;
else /* lr_usr == lr in a user frame */
return ®s->lr;
case PSR_MODE_FIQ:
return ®s->sp_fiq + reg - 13;
case PSR_MODE_IRQ:
return ®s->sp_irq + reg - 13;
case PSR_MODE_SVC:
return ®s->sp_svc + reg - 13;
case PSR_MODE_ABT:
return ®s->sp_abt + reg - 13;
case PSR_MODE_UND:
return ®s->sp_und + reg - 13;
case PSR_MODE_MON:
case PSR_MODE_HYP:
default:
BUG();
}
case 15: /* PC */
return ®s->pc;
default:
BUG();
}
#undef REGOFFS
#else
/* In 64 bit the syndrome register contains the AArch64 register
* number even if the trap was from AArch32 mode. Except that
* AArch32 R15 (PC) is encoded as 0b11111.
*/
if ( reg == 0x1f /* && is aarch32 guest */)
return ®s->pc;
return ®s->x0 + reg;
#endif
}
static const char *decode_fsc(uint32_t fsc, int *level)
{
const char *msg = NULL;
switch ( fsc & 0x3f )
{
case FSC_FLT_TRANS ... FSC_FLT_TRANS + 3:
msg = "Translation fault";
*level = fsc & FSC_LL_MASK;
break;
case FSC_FLT_ACCESS ... FSC_FLT_ACCESS + 3:
msg = "Access fault";
*level = fsc & FSC_LL_MASK;
break;
case FSC_FLT_PERM ... FSC_FLT_PERM + 3:
msg = "Permission fault";
*level = fsc & FSC_LL_MASK;
break;
case FSC_SEA:
msg = "Synchronous External Abort";
break;
case FSC_SPE:
msg = "Memory Access Synchronous Parity Error";
break;
case FSC_APE:
msg = "Memory Access Asynchronous Parity Error";
break;
case FSC_SEATT ... FSC_SEATT + 3:
msg = "Sync. Ext. Abort Translation Table";
*level = fsc & FSC_LL_MASK;
break;
case FSC_SPETT ... FSC_SPETT + 3:
msg = "Sync. Parity. Error Translation Table";
*level = fsc & FSC_LL_MASK;
break;
case FSC_AF:
msg = "Alignment Fault";
break;
case FSC_DE:
msg = "Debug Event";
break;
case FSC_LKD:
msg = "Implementation Fault: Lockdown Abort";
break;
case FSC_CPR:
msg = "Implementation Fault: Coprocossor Abort";
break;
default:
msg = "Unknown Failure";
break;
}
return msg;
}
static const char *fsc_level_str(int level)
{
switch ( level )
{
case -1: return "";
case 1: return " at level 1";
case 2: return " at level 2";
case 3: return " at level 3";
default: return " (level invalid)";
}
}
void panic_PAR(uint64_t par)
{
const char *msg;
int level = -1;
int stage = par & PAR_STAGE2 ? 2 : 1;
int second_in_first = !!(par & PAR_STAGE21);
msg = decode_fsc( (par&PAR_FSC_MASK) >> PAR_FSC_SHIFT, &level);
printk("PAR: %016"PRIx64": %s stage %d%s%s\n",
par, msg,
stage,
second_in_first ? " during second stage lookup" : "",
fsc_level_str(level));
panic("Error during Hypervisor-to-physical address translation");
}
static void cpsr_switch_mode(struct cpu_user_regs *regs, int mode)
{
uint32_t sctlr = READ_SYSREG32(SCTLR_EL1);
regs->cpsr &= ~(PSR_MODE_MASK|PSR_IT_MASK|PSR_JAZELLE|PSR_BIG_ENDIAN|PSR_THUMB);
regs->cpsr |= mode;
regs->cpsr |= PSR_IRQ_MASK;
if ( mode == PSR_MODE_ABT )
regs->cpsr |= PSR_ABT_MASK;
if ( sctlr & SCTLR_TE )
regs->cpsr |= PSR_THUMB;
if ( sctlr & SCTLR_EE )
regs->cpsr |= PSR_BIG_ENDIAN;
}
static vaddr_t exception_handler32(vaddr_t offset)
{
uint32_t sctlr = READ_SYSREG32(SCTLR_EL1);
if (sctlr & SCTLR_V)
return 0xffff0000 + offset;
else /* always have security exceptions */
return READ_SYSREG(VBAR_EL1) + offset;
}
/* Injects an Undefined Instruction exception into the current vcpu,
* PC is the exact address of the faulting instruction (without
* pipeline adjustments). See TakeUndefInstrException pseudocode in
* ARM ARM.
*/
static void inject_undef32_exception(struct cpu_user_regs *regs)
{
uint32_t spsr = regs->cpsr;
int is_thumb = (regs->cpsr & PSR_THUMB);
/* Saved PC points to the instruction past the faulting instruction. */
uint32_t return_offset = is_thumb ? 2 : 4;
BUG_ON( !is_32bit_domain(current->domain) );
/* Update processor mode */
cpsr_switch_mode(regs, PSR_MODE_UND);
/* Update banked registers */
regs->spsr_und = spsr;
regs->lr_und = regs->pc32 + return_offset;
/* Branch to exception vector */
regs->pc32 = exception_handler32(VECTOR32_UND);
}
/* Injects an Abort exception into the current vcpu, PC is the exact
* address of the faulting instruction (without pipeline
* adjustments). See TakePrefetchAbortException and
* TakeDataAbortException pseudocode in ARM ARM.
*/
static void inject_abt32_exception(struct cpu_user_regs *regs,
int prefetch,
register_t addr)
{
uint32_t spsr = regs->cpsr;
int is_thumb = (regs->cpsr & PSR_THUMB);
/* Saved PC points to the instruction past the faulting instruction. */
uint32_t return_offset = is_thumb ? 4 : 0;
register_t fsr;
BUG_ON( !is_32bit_domain(current->domain) );
cpsr_switch_mode(regs, PSR_MODE_ABT);
/* Update banked registers */
regs->spsr_abt = spsr;
regs->lr_abt = regs->pc32 + return_offset;
regs->pc32 = exception_handler32(prefetch ? VECTOR32_PABT : VECTOR32_DABT);
/* Inject a debug fault, best we can do right now */
if ( READ_SYSREG(TCR_EL1) & TTBCR_EAE )
fsr = FSR_LPAE | FSRL_STATUS_DEBUG;
else
fsr = FSRS_FS_DEBUG;
if ( prefetch )
{
/* Set IFAR and IFSR */
#ifdef CONFIG_ARM_32
WRITE_SYSREG(addr, IFAR);
WRITE_SYSREG(fsr, IFSR);
#else
/* FAR_EL1[63:32] is AArch32 register IFAR */
register_t far = READ_SYSREG(FAR_EL1) & 0xffffffffUL;
far |= addr << 32;
WRITE_SYSREG(far, FAR_EL1);
WRITE_SYSREG(fsr, IFSR32_EL2);
#endif
}
else
{
#ifdef CONFIG_ARM_32
/* Set DFAR and DFSR */
WRITE_SYSREG(addr, DFAR);
WRITE_SYSREG(fsr, DFSR);
#else
/* FAR_EL1[31:0] is AArch32 register DFAR */
register_t far = READ_SYSREG(FAR_EL1) & ~0xffffffffUL;
far |= addr;
WRITE_SYSREG(far, FAR_EL1);
/* ESR_EL1 is AArch32 register DFSR */
WRITE_SYSREG(fsr, ESR_EL1);
#endif
}
}
static void inject_dabt32_exception(struct cpu_user_regs *regs,
register_t addr)
{
inject_abt32_exception(regs, 0, addr);
}
static void inject_pabt32_exception(struct cpu_user_regs *regs,
register_t addr)
{
inject_abt32_exception(regs, 1, addr);
}
#ifdef CONFIG_ARM_64
/*
* Take care to call this while regs contains the original faulting
* state and not the (partially constructed) exception state.
*/
static vaddr_t exception_handler64(struct cpu_user_regs *regs, vaddr_t offset)
{
vaddr_t base = READ_SYSREG(VBAR_EL1);
if ( usr_mode(regs) )
base += VECTOR64_LOWER32_BASE;
else if ( psr_mode(regs->cpsr,PSR_MODE_EL0t) )
base += VECTOR64_LOWER64_BASE;
else /* Otherwise must be from kernel mode */
base += VECTOR64_CURRENT_SPx_BASE;
return base + offset;
}
/* Inject an undefined exception into a 64 bit guest */
static void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len)
{
vaddr_t handler;
union hsr esr = {
.iss = 0,
.len = instr_len,
.ec = HSR_EC_UNKNOWN,
};
BUG_ON( is_32bit_domain(current->domain) );
handler = exception_handler64(regs, VECTOR64_SYNC_OFFSET);
regs->spsr_el1 = regs->cpsr;
regs->elr_el1 = regs->pc;
regs->cpsr = PSR_MODE_EL1h | PSR_ABT_MASK | PSR_FIQ_MASK | \
PSR_IRQ_MASK | PSR_DBG_MASK;
regs->pc = handler;
WRITE_SYSREG32(esr.bits, ESR_EL1);
}
/* Inject an abort exception into a 64 bit guest */
static void inject_abt64_exception(struct cpu_user_regs *regs,
int prefetch,
register_t addr,
int instr_len)
{
vaddr_t handler;
union hsr esr = {
.iss = 0,
.len = instr_len,
};
if ( psr_mode_is_user(regs) )
esr.ec = prefetch
? HSR_EC_INSTR_ABORT_LOWER_EL : HSR_EC_DATA_ABORT_LOWER_EL;
else
esr.ec = prefetch
? HSR_EC_INSTR_ABORT_CURR_EL : HSR_EC_DATA_ABORT_CURR_EL;
BUG_ON( is_32bit_domain(current->domain) );
handler = exception_handler64(regs, VECTOR64_SYNC_OFFSET);
regs->spsr_el1 = regs->cpsr;
regs->elr_el1 = regs->pc;
regs->cpsr = PSR_MODE_EL1h | PSR_ABT_MASK | PSR_FIQ_MASK | \
PSR_IRQ_MASK | PSR_DBG_MASK;
regs->pc = handler;
WRITE_SYSREG(addr, FAR_EL1);
WRITE_SYSREG32(esr.bits, ESR_EL1);
}
static void inject_dabt64_exception(struct cpu_user_regs *regs,
register_t addr,
int instr_len)
{
inject_abt64_exception(regs, 0, addr, instr_len);
}
static void inject_iabt64_exception(struct cpu_user_regs *regs,
register_t addr,
int instr_len)
{
inject_abt64_exception(regs, 1, addr, instr_len);
}
#endif
static void inject_undef_exception(struct cpu_user_regs *regs,
int instr_len)
{
if ( is_32bit_domain(current->domain) )
inject_undef32_exception(regs);
#ifdef CONFIG_ARM_64
else
inject_undef64_exception(regs, instr_len);
#endif
}
static void inject_iabt_exception(struct cpu_user_regs *regs,
register_t addr,
int instr_len)
{
if ( is_32bit_domain(current->domain) )
inject_pabt32_exception(regs, addr);
#ifdef CONFIG_ARM_64
else
inject_iabt64_exception(regs, addr, instr_len);
#endif
}
static void inject_dabt_exception(struct cpu_user_regs *regs,
register_t addr,
int instr_len)
{
if ( is_32bit_domain(current->domain) )
inject_dabt32_exception(regs, addr);
#ifdef CONFIG_ARM_64
else
inject_dabt64_exception(regs, addr, instr_len);
#endif
}
struct reg_ctxt {
/* Guest-side state */
uint32_t sctlr_el1;
register_t tcr_el1;
uint64_t ttbr0_el1, ttbr1_el1;
#ifdef CONFIG_ARM_32
uint32_t dfsr, ifsr;
uint32_t dfar, ifar;
#else
uint32_t esr_el1;
uint64_t far;
uint32_t ifsr32_el2;
#endif
/* Hypervisor-side state */
uint64_t vttbr_el2;
};
static const char *mode_string(uint32_t cpsr)
{
uint32_t mode;
static const char *mode_strings[] = {
[PSR_MODE_USR] = "32-bit Guest USR",
[PSR_MODE_FIQ] = "32-bit Guest FIQ",
[PSR_MODE_IRQ] = "32-bit Guest IRQ",
[PSR_MODE_SVC] = "32-bit Guest SVC",
[PSR_MODE_MON] = "32-bit Monitor",
[PSR_MODE_ABT] = "32-bit Guest ABT",
[PSR_MODE_HYP] = "Hypervisor",
[PSR_MODE_UND] = "32-bit Guest UND",
[PSR_MODE_SYS] = "32-bit Guest SYS",
#ifdef CONFIG_ARM_64
[PSR_MODE_EL3h] = "64-bit EL3h (Monitor, handler)",
[PSR_MODE_EL3t] = "64-bit EL3t (Monitor, thread)",
[PSR_MODE_EL2h] = "64-bit EL2h (Hypervisor, handler)",
[PSR_MODE_EL2t] = "64-bit EL2t (Hypervisor, thread)",
[PSR_MODE_EL1h] = "64-bit EL1h (Guest Kernel, handler)",
[PSR_MODE_EL1t] = "64-bit EL1t (Guest Kernel, thread)",
[PSR_MODE_EL0t] = "64-bit EL0t (Guest User)",
#endif
};
mode = cpsr & PSR_MODE_MASK;
if ( mode > ARRAY_SIZE(mode_strings) )
return "Unknown";
return mode_strings[mode] ? : "Unknown";
}
static void show_registers_32(struct cpu_user_regs *regs,
struct reg_ctxt *ctxt,
int guest_mode,
const struct vcpu *v)
{
#ifdef CONFIG_ARM_64
BUG_ON( ! (regs->cpsr & PSR_MODE_BIT) );
printk("PC: %08"PRIx32"\n", regs->pc32);
#else
printk("PC: %08"PRIx32, regs->pc);
if ( !guest_mode )
printk(" %pS", _p(regs->pc));
printk("\n");
#endif
printk("CPSR: %08"PRIx32" MODE:%s\n", regs->cpsr,
mode_string(regs->cpsr));
printk(" R0: %08"PRIx32" R1: %08"PRIx32" R2: %08"PRIx32" R3: %08"PRIx32"\n",
regs->r0, regs->r1, regs->r2, regs->r3);
printk(" R4: %08"PRIx32" R5: %08"PRIx32" R6: %08"PRIx32" R7: %08"PRIx32"\n",
regs->r4, regs->r5, regs->r6, regs->r7);
printk(" R8: %08"PRIx32" R9: %08"PRIx32" R10:%08"PRIx32" R11:%08"PRIx32" R12:%08"PRIx32"\n",
regs->r8, regs->r9, regs->r10,
#ifdef CONFIG_ARM_64
regs->r11,
#else
regs->fp,
#endif
regs->r12);
if ( guest_mode )
{
printk("USR: SP: %08"PRIx32" LR: %08"PRIregister"\n",
regs->sp_usr, regs->lr);
printk("SVC: SP: %08"PRIx32" LR: %08"PRIx32" SPSR:%08"PRIx32"\n",
regs->sp_svc, regs->lr_svc, regs->spsr_svc);
printk("ABT: SP: %08"PRIx32" LR: %08"PRIx32" SPSR:%08"PRIx32"\n",
regs->sp_abt, regs->lr_abt, regs->spsr_abt);
printk("UND: SP: %08"PRIx32" LR: %08"PRIx32" SPSR:%08"PRIx32"\n",
regs->sp_und, regs->lr_und, regs->spsr_und);
printk("IRQ: SP: %08"PRIx32" LR: %08"PRIx32" SPSR:%08"PRIx32"\n",
regs->sp_irq, regs->lr_irq, regs->spsr_irq);
printk("FIQ: SP: %08"PRIx32" LR: %08"PRIx32" SPSR:%08"PRIx32"\n",
regs->sp_fiq, regs->lr_fiq, regs->spsr_fiq);
printk("FIQ: R8: %08"PRIx32" R9: %08"PRIx32" R10:%08"PRIx32" R11:%08"PRIx32" R12:%08"PRIx32"\n",
regs->r8_fiq, regs->r9_fiq, regs->r10_fiq, regs->r11_fiq, regs->r11_fiq);
}
#ifndef CONFIG_ARM_64
else
{
printk("HYP: SP: %08"PRIx32" LR: %08"PRIregister"\n", regs->sp, regs->lr);
}
#endif
printk("\n");
if ( guest_mode )
{
printk(" SCTLR: %08"PRIx32"\n", ctxt->sctlr_el1);
printk(" TCR: %08"PRIregister"\n", ctxt->tcr_el1);
printk(" TTBR0: %016"PRIx64"\n", ctxt->ttbr0_el1);
printk(" TTBR1: %016"PRIx64"\n", ctxt->ttbr1_el1);
printk(" IFAR: %08"PRIx32", IFSR: %08"PRIx32"\n"
" DFAR: %08"PRIx32", DFSR: %08"PRIx32"\n",
#ifdef CONFIG_ARM_64
(uint32_t)(ctxt->far >> 32),
ctxt->ifsr32_el2,
(uint32_t)(ctxt->far & 0xffffffff),
ctxt->esr_el1
#else
ctxt->ifar, ctxt->ifsr, ctxt->dfar, ctxt->dfsr
#endif
);
printk("\n");
}
}
#ifdef CONFIG_ARM_64
static void show_registers_64(struct cpu_user_regs *regs,
struct reg_ctxt *ctxt,
int guest_mode,
const struct vcpu *v)
{
BUG_ON( (regs->cpsr & PSR_MODE_BIT) );
printk("PC: %016"PRIx64, regs->pc);
if ( !guest_mode )
printk(" %pS", _p(regs->pc));
printk("\n");
printk("LR: %016"PRIx64"\n", regs->lr);
if ( guest_mode )
{
printk("SP_EL0: %016"PRIx64"\n", regs->sp_el0);
printk("SP_EL1: %016"PRIx64"\n", regs->sp_el1);
}
else
{
printk("SP: %016"PRIx64"\n", regs->sp);
}
printk("CPSR: %08"PRIx32" MODE:%s\n", regs->cpsr,
mode_string(regs->cpsr));
printk(" X0: %016"PRIx64" X1: %016"PRIx64" X2: %016"PRIx64"\n",
regs->x0, regs->x1, regs->x2);
printk(" X3: %016"PRIx64" X4: %016"PRIx64" X5: %016"PRIx64"\n",
regs->x3, regs->x4, regs->x5);
printk(" X6: %016"PRIx64" X7: %016"PRIx64" X8: %016"PRIx64"\n",
regs->x6, regs->x7, regs->x8);
printk(" X9: %016"PRIx64" X10: %016"PRIx64" X11: %016"PRIx64"\n",
regs->x9, regs->x10, regs->x11);
printk(" X12: %016"PRIx64" X13: %016"PRIx64" X14: %016"PRIx64"\n",
regs->x12, regs->x13, regs->x14);
printk(" X15: %016"PRIx64" X16: %016"PRIx64" X17: %016"PRIx64"\n",
regs->x15, regs->x16, regs->x17);
printk(" X18: %016"PRIx64" X19: %016"PRIx64" X20: %016"PRIx64"\n",
regs->x18, regs->x19, regs->x20);
printk(" X21: %016"PRIx64" X22: %016"PRIx64" X23: %016"PRIx64"\n",
regs->x21, regs->x22, regs->x23);
printk(" X24: %016"PRIx64" X25: %016"PRIx64" X26: %016"PRIx64"\n",
regs->x24, regs->x25, regs->x26);
printk(" X27: %016"PRIx64" X28: %016"PRIx64" FP: %016"PRIx64"\n",
regs->x27, regs->x28, regs->fp);
printk("\n");
if ( guest_mode )
{
printk(" ELR_EL1: %016"PRIx64"\n", regs->elr_el1);
printk(" ESR_EL1: %08"PRIx32"\n", ctxt->esr_el1);
printk(" FAR_EL1: %016"PRIx64"\n", ctxt->far);
printk("\n");
printk(" SCTLR_EL1: %08"PRIx32"\n", ctxt->sctlr_el1);
printk(" TCR_EL1: %08"PRIregister"\n", ctxt->tcr_el1);
printk(" TTBR0_EL1: %016"PRIx64"\n", ctxt->ttbr0_el1);
printk(" TTBR1_EL1: %016"PRIx64"\n", ctxt->ttbr1_el1);
printk("\n");
}
}
#endif
static void _show_registers(struct cpu_user_regs *regs,
struct reg_ctxt *ctxt,
int guest_mode,
const struct vcpu *v)
{
print_xen_info();
printk("CPU: %d\n", smp_processor_id());
if ( guest_mode )
{
if ( is_32bit_domain(v->domain) )
show_registers_32(regs, ctxt, guest_mode, v);
#ifdef CONFIG_ARM_64
else if ( is_64bit_domain(v->domain) )
{
if ( psr_mode_is_32bit(regs->cpsr) )
{
BUG_ON(!usr_mode(regs));
show_registers_32(regs, ctxt, guest_mode, v);
}
else
{
show_registers_64(regs, ctxt, guest_mode, v);
}
}
#endif
}
else
{
#ifdef CONFIG_ARM_64
show_registers_64(regs, ctxt, guest_mode, v);
#else
show_registers_32(regs, ctxt, guest_mode, v);
#endif
}
printk(" VTCR_EL2: %08"PRIx32"\n", READ_SYSREG32(VTCR_EL2));
printk(" VTTBR_EL2: %016"PRIx64"\n", ctxt->vttbr_el2);
printk("\n");
printk(" SCTLR_EL2: %08"PRIx32"\n", READ_SYSREG32(SCTLR_EL2));
printk(" HCR_EL2: %016"PRIregister"\n", READ_SYSREG(HCR_EL2));
printk(" TTBR0_EL2: %016"PRIx64"\n", READ_SYSREG64(TTBR0_EL2));
printk("\n");
printk(" ESR_EL2: %08"PRIx32"\n", READ_SYSREG32(ESR_EL2));
printk(" HPFAR_EL2: %016"PRIregister"\n", READ_SYSREG(HPFAR_EL2));
#ifdef CONFIG_ARM_32
printk(" HDFAR: %08"PRIx32"\n", READ_CP32(HDFAR));
printk(" HIFAR: %08"PRIx32"\n", READ_CP32(HIFAR));
#else
printk(" FAR_EL2: %016"PRIx64"\n", READ_SYSREG64(FAR_EL2));
#endif
printk("\n");
}
void show_registers(struct cpu_user_regs *regs)
{
struct reg_ctxt ctxt;
ctxt.sctlr_el1 = READ_SYSREG(SCTLR_EL1);
ctxt.tcr_el1 = READ_SYSREG(TCR_EL1);
ctxt.ttbr0_el1 = READ_SYSREG64(TTBR0_EL1);
ctxt.ttbr1_el1 = READ_SYSREG64(TTBR1_EL1);
#ifdef CONFIG_ARM_32
ctxt.dfar = READ_CP32(DFAR);
ctxt.ifar = READ_CP32(IFAR);
ctxt.dfsr = READ_CP32(DFSR);
ctxt.ifsr = READ_CP32(IFSR);
#else
ctxt.far = READ_SYSREG(FAR_EL1);
ctxt.esr_el1 = READ_SYSREG(ESR_EL1);
if ( guest_mode(regs) && is_32bit_domain(current->domain) )
ctxt.ifsr32_el2 = READ_SYSREG(IFSR32_EL2);
#endif
ctxt.vttbr_el2 = READ_SYSREG64(VTTBR_EL2);
_show_registers(regs, &ctxt, guest_mode(regs), current);
}
void vcpu_show_registers(const struct vcpu *v)
{
struct reg_ctxt ctxt;
ctxt.sctlr_el1 = v->arch.sctlr;
ctxt.tcr_el1 = v->arch.ttbcr;
ctxt.ttbr0_el1 = v->arch.ttbr0;
ctxt.ttbr1_el1 = v->arch.ttbr1;
#ifdef CONFIG_ARM_32
ctxt.dfar = v->arch.dfar;
ctxt.ifar = v->arch.ifar;
ctxt.dfsr = v->arch.dfsr;
ctxt.ifsr = v->arch.ifsr;
#else
ctxt.far = v->arch.far;
ctxt.esr_el1 = v->arch.esr;
ctxt.ifsr32_el2 = v->arch.ifsr;
#endif
ctxt.vttbr_el2 = v->domain->arch.vttbr;
_show_registers(&v->arch.cpu_info->guest_cpu_user_regs, &ctxt, 1, v);
}
static void show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs)
{
int i;
vaddr_t sp;
struct page_info *page;
void *mapped;
unsigned long *stack, addr;
if ( test_bit(_VPF_down, &v->pause_flags) )
{
printk("No stack trace, VCPU offline\n");
return;
}
switch ( regs->cpsr & PSR_MODE_MASK )
{
case PSR_MODE_USR:
case PSR_MODE_SYS:
#ifdef CONFIG_ARM_64
case PSR_MODE_EL0t:
#endif
printk("No stack trace for guest user-mode\n");
return;
case PSR_MODE_FIQ:
sp = regs->sp_fiq;
break;
case PSR_MODE_IRQ:
sp = regs->sp_irq;
break;
case PSR_MODE_SVC:
sp = regs->sp_svc;
break;
case PSR_MODE_ABT:
sp = regs->sp_abt;
break;
case PSR_MODE_UND:
sp = regs->sp_und;
break;
#ifdef CONFIG_ARM_64
case PSR_MODE_EL1t:
sp = regs->sp_el0;
break;
case PSR_MODE_EL1h:
sp = regs->sp_el1;
break;
#endif
case PSR_MODE_HYP:
case PSR_MODE_MON:
#ifdef CONFIG_ARM_64
case PSR_MODE_EL3h:
case PSR_MODE_EL3t:
case PSR_MODE_EL2h:
case PSR_MODE_EL2t:
#endif
default:
BUG();
return;
}
printk("Guest stack trace from sp=%"PRIvaddr":\n ", sp);
if ( sp & ( sizeof(long) - 1 ) )
{
printk("Stack is misaligned\n");
return;
}
page = get_page_from_gva(v->domain, sp, GV2M_READ);
if ( page == NULL )
{
printk("Failed to convert stack to physical address\n");
return;
}
mapped = __map_domain_page(page);
stack = mapped + (sp & ~PAGE_MASK);
for ( i = 0; i < (debug_stack_lines*stack_words_per_line); i++ )
{
if ( (((long)stack - 1) ^ ((long)(stack + 1) - 1)) & PAGE_SIZE )
break;
addr = *stack;
if ( (i != 0) && ((i % stack_words_per_line) == 0) )
printk("\n ");
printk(" %p", _p(addr));
stack++;
}
if ( i == 0 )
printk("Stack empty.");
printk("\n");
unmap_domain_page(mapped);
put_page(page);
}
#define STACK_BEFORE_EXCEPTION(regs) ((register_t*)(regs)->sp)
#ifdef CONFIG_ARM_32
/* Frame pointer points to the return address:
* (largest address)
* | cpu_info
* | [...] |
* | return addr <-----------------, |
* | fp --------------------------------+----'
* | [...] |
* | return addr <------------, |
* | fp ---------------------------+----'
* | [...] |
* | return addr <- regs->fp |
* | fp ---------------------------'
* |
* v (smallest address, sp)
*/
#define STACK_FRAME_BASE(fp) ((register_t*)(fp) - 1)
#else
/* Frame pointer points to the next frame:
* (largest address)
* | cpu_info
* | [...] |
* | return addr |
* | fp <-------------------------------, >--'
* | [...] |
* | return addr |
* | fp <--------------------------, >--'
* | [...] |
* | return addr <- regs->fp |
* | fp ---------------------------'
* |
* v (smallest address, sp)
*/
#define STACK_FRAME_BASE(fp) ((register_t*)(fp))
#endif
static void show_trace(struct cpu_user_regs *regs)
{
register_t *frame, next, addr, low, high;
printk("Xen call trace:\n");
printk(" [<%p>] %pS (PC)\n", _p(regs->pc), _p(regs->pc));
printk(" [<%p>] %pS (LR)\n", _p(regs->lr), _p(regs->lr));
/* Bounds for range of valid frame pointer. */
low = (register_t)(STACK_BEFORE_EXCEPTION(regs));
high = (low & ~(STACK_SIZE - 1)) +
(STACK_SIZE - sizeof(struct cpu_info));
/* The initial frame pointer. */
next = regs->fp;
for ( ; ; )
{
if ( (next < low) || (next >= high) )
break;
/* Ordinary stack frame. */
frame = STACK_FRAME_BASE(next);
next = frame[0];
addr = frame[1];
printk(" [<%p>] %pS\n", _p(addr), _p(addr));
low = (register_t)&frame[1];
}
printk("\n");
}
void show_stack(struct cpu_user_regs *regs)
{
register_t *stack = STACK_BEFORE_EXCEPTION(regs), addr;
int i;
if ( guest_mode(regs) )
return show_guest_stack(current, regs);
printk("Xen stack trace from sp=%p:\n ", stack);
for ( i = 0; i < (debug_stack_lines*stack_words_per_line); i++ )
{
if ( ((long)stack & (STACK_SIZE-BYTES_PER_LONG)) == 0 )
break;
if ( (i != 0) && ((i % stack_words_per_line) == 0) )
printk("\n ");
addr = *stack++;
printk(" %p", _p(addr));
}
if ( i == 0 )
printk("Stack empty.");
printk("\n");
show_trace(regs);
}
void show_execution_state(struct cpu_user_regs *regs)
{
show_registers(regs);
show_stack(regs);
}
void vcpu_show_execution_state(struct vcpu *v)
{
printk("*** Dumping Dom%d vcpu#%d state: ***\n",
v->domain->domain_id, v->vcpu_id);
if ( v == current )
{
show_execution_state(guest_cpu_user_regs());
return;
}
vcpu_pause(v); /* acceptably dangerous */
vcpu_show_registers(v);
if ( !usr_mode(&v->arch.cpu_info->guest_cpu_user_regs) )
show_guest_stack(v, &v->arch.cpu_info->guest_cpu_user_regs);
vcpu_unpause(v);
}
void do_unexpected_trap(const char *msg, struct cpu_user_regs *regs)
{
printk("CPU%d: Unexpected Trap: %s\n", smp_processor_id(), msg);
show_execution_state(regs);
panic("CPU%d: Unexpected Trap: %s\n", smp_processor_id(), msg);
}
int do_bug_frame(struct cpu_user_regs *regs, vaddr_t pc)
{
const struct bug_frame *bug;
const char *prefix = "", *filename, *predicate;
unsigned long fixup;
int id, lineno;
static const struct bug_frame *const stop_frames[] = {
__stop_bug_frames_0,
__stop_bug_frames_1,
__stop_bug_frames_2,
NULL
};
for ( bug = __start_bug_frames, id = 0; stop_frames[id]; ++bug )
{
while ( unlikely(bug == stop_frames[id]) )
++id;
if ( ((vaddr_t)bug_loc(bug)) == pc )
break;
}
if ( !stop_frames[id] )
return -ENOENT;
/* WARN, BUG or ASSERT: decode the filename pointer and line number. */
filename = bug_file(bug);
if ( !is_kernel(filename) )
return -EINVAL;
fixup = strlen(filename);
if ( fixup > 50 )
{
filename += fixup - 47;
prefix = "...";
}
lineno = bug_line(bug);
switch ( id )
{
case BUGFRAME_warn:
printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
show_execution_state(regs);
return 0;
case BUGFRAME_bug:
printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
if ( debugger_trap_fatal(TRAP_invalid_op, regs) )
return 0;
show_execution_state(regs);
panic("Xen BUG at %s%s:%d", prefix, filename, lineno);
case BUGFRAME_assert:
/* ASSERT: decode the predicate string pointer. */
predicate = bug_msg(bug);
if ( !is_kernel(predicate) )
predicate = "<unknown>";
printk("Assertion '%s' failed at %s%s:%d\n",
predicate, prefix, filename, lineno);
if ( debugger_trap_fatal(TRAP_invalid_op, regs) )
return 0;
show_execution_state(regs);
panic("Assertion '%s' failed at %s%s:%d",
predicate, prefix, filename, lineno);
}
return -EINVAL;
}
#ifdef CONFIG_ARM_64
static void do_trap_brk(struct cpu_user_regs *regs, union hsr hsr)
{
/* HCR_EL2.TGE and MDCR_EL2.TDE are not set so we never receive
* software breakpoint exception for EL1 and EL0 here.
*/
BUG_ON(!hyp_mode(regs));
switch (hsr.brk.comment)
{
case BRK_BUG_FRAME:
if ( do_bug_frame(regs, regs->pc) )
goto die;
regs->pc += 4;
break;
default:
die:
do_unexpected_trap("Undefined Breakpoint Value", regs);
}
}
#endif
typedef register_t (*arm_hypercall_fn_t)(
register_t, register_t, register_t, register_t, register_t);
typedef struct {
arm_hypercall_fn_t fn;
int nr_args;
} arm_hypercall_t;
#define HYPERCALL(_name, _nr_args) \
[ __HYPERVISOR_ ## _name ] = { \
.fn = (arm_hypercall_fn_t) &do_ ## _name, \
.nr_args = _nr_args, \
}
#define HYPERCALL_ARM(_name, _nr_args) \
[ __HYPERVISOR_ ## _name ] = { \
.fn = (arm_hypercall_fn_t) &do_arm_ ## _name, \
.nr_args = _nr_args, \
}
static arm_hypercall_t arm_hypercall_table[] = {
HYPERCALL(memory_op, 2),
HYPERCALL(domctl, 1),
HYPERCALL(sched_op, 2),
HYPERCALL(console_io, 3),
HYPERCALL(xen_version, 2),
HYPERCALL(xsm_op, 1),
HYPERCALL(event_channel_op, 2),
HYPERCALL(physdev_op, 2),
HYPERCALL(sysctl, 2),
HYPERCALL(hvm_op, 2),
HYPERCALL(grant_table_op, 3),
HYPERCALL(multicall, 2),
HYPERCALL_ARM(vcpu_op, 3),
};
#ifndef NDEBUG
static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
{
register_t *r;
uint32_t reg;
uint32_t domid = current->domain->domain_id;
switch ( code ) {
case 0xe0 ... 0xef:
reg = code - 0xe0;
r = select_user_reg(regs, reg);
printk("DOM%d: R%d = 0x%"PRIregister" at 0x%"PRIvaddr"\n",
domid, reg, *r, regs->pc);
break;
case 0xfd:
printk("DOM%d: Reached %"PRIvaddr"\n", domid, regs->pc);
break;
case 0xfe:
r = select_user_reg(regs, 0);
printk("%c", (char)(*r & 0xff));
break;
case 0xff:
printk("DOM%d: DEBUG\n", domid);
show_execution_state(regs);
break;
default:
panic("DOM%d: Unhandled debug trap %#x", domid, code);
break;
}
}
#endif
#ifdef CONFIG_ARM_64
#define PSCI_RESULT_REG(reg) (reg)->x0
#define PSCI_ARG(reg,n) (reg)->x##n
#define PSCI_ARG32(reg,n) (uint32_t)( (reg)->x##n & 0x00000000FFFFFFFF )
#else
#define PSCI_RESULT_REG(reg) (reg)->r0
#define PSCI_ARG(reg,n) (reg)->r##n
#define PSCI_ARG32(reg,n) PSCI_ARG(reg,n)
#endif
/* helper function for checking arm mode 32/64 bit */
static inline int psci_mode_check(struct domain *d, register_t fid)
{
return !( is_64bit_domain(d)^( (fid & PSCI_0_2_64BIT) >> 30 ) );
}
static void do_trap_psci(struct cpu_user_regs *regs)
{
register_t fid = PSCI_ARG(regs,0);
/* preloading in case psci_mode_check fails */
PSCI_RESULT_REG(regs) = PSCI_INVALID_PARAMETERS;
switch( fid )
{
case PSCI_cpu_off:
{
uint32_t pstate = PSCI_ARG32(regs,1);
PSCI_RESULT_REG(regs) = do_psci_cpu_off(pstate);
}
break;
case PSCI_cpu_on:
{
uint32_t vcpuid = PSCI_ARG32(regs,1);
register_t epoint = PSCI_ARG(regs,2);
PSCI_RESULT_REG(regs) = do_psci_cpu_on(vcpuid, epoint);
}
break;
case PSCI_0_2_FN_PSCI_VERSION:
PSCI_RESULT_REG(regs) = do_psci_0_2_version();
break;
case PSCI_0_2_FN_CPU_OFF:
PSCI_RESULT_REG(regs) = do_psci_0_2_cpu_off();
break;
case PSCI_0_2_FN_MIGRATE_INFO_TYPE:
PSCI_RESULT_REG(regs) = do_psci_0_2_migrate_info_type();
break;
case PSCI_0_2_FN_MIGRATE_INFO_UP_CPU:
case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU:
if ( psci_mode_check(current->domain, fid) )
PSCI_RESULT_REG(regs) = do_psci_0_2_migrate_info_up_cpu();
break;
case PSCI_0_2_FN_SYSTEM_OFF:
do_psci_0_2_system_off();
PSCI_RESULT_REG(regs) = PSCI_INTERNAL_FAILURE;
break;
case PSCI_0_2_FN_SYSTEM_RESET:
do_psci_0_2_system_reset();
PSCI_RESULT_REG(regs) = PSCI_INTERNAL_FAILURE;
break;
case PSCI_0_2_FN_CPU_ON:
case PSCI_0_2_FN64_CPU_ON:
if ( psci_mode_check(current->domain, fid) )
{
register_t vcpuid = PSCI_ARG(regs,1);
register_t epoint = PSCI_ARG(regs,2);
register_t cid = PSCI_ARG(regs,3);
PSCI_RESULT_REG(regs) =
do_psci_0_2_cpu_on(vcpuid, epoint, cid);
}
break;
case PSCI_0_2_FN_CPU_SUSPEND:
case PSCI_0_2_FN64_CPU_SUSPEND:
if ( psci_mode_check(current->domain, fid) )
{
uint32_t pstate = PSCI_ARG32(regs,1);
register_t epoint = PSCI_ARG(regs,2);
register_t cid = PSCI_ARG(regs,3);
PSCI_RESULT_REG(regs) =
do_psci_0_2_cpu_suspend(pstate, epoint, cid);
}
break;
case PSCI_0_2_FN_AFFINITY_INFO:
case PSCI_0_2_FN64_AFFINITY_INFO:
if ( psci_mode_check(current->domain, fid) )
{
register_t taff = PSCI_ARG(regs,1);
uint32_t laff = PSCI_ARG32(regs,2);
PSCI_RESULT_REG(regs) =
do_psci_0_2_affinity_info(taff, laff);
}
break;
case PSCI_0_2_FN_MIGRATE:
case PSCI_0_2_FN64_MIGRATE:
if ( psci_mode_check(current->domain, fid) )
{
uint32_t tcpu = PSCI_ARG32(regs,1);
PSCI_RESULT_REG(regs) = do_psci_0_2_migrate(tcpu);
}
break;
default:
domain_crash_synchronous();
return;
}
}
#ifdef CONFIG_ARM_64
#define HYPERCALL_RESULT_REG(r) (r)->x0
#define HYPERCALL_ARG1(r) (r)->x0
#define HYPERCALL_ARG2(r) (r)->x1
#define HYPERCALL_ARG3(r) (r)->x2
#define HYPERCALL_ARG4(r) (r)->x3
#define HYPERCALL_ARG5(r) (r)->x4
#define HYPERCALL_ARGS(r) (r)->x0, (r)->x1, (r)->x2, (r)->x3, (r)->x4
#else
#define HYPERCALL_RESULT_REG(r) (r)->r0
#define HYPERCALL_ARG1(r) (r)->r0
#define HYPERCALL_ARG2(r) (r)->r1
#define HYPERCALL_ARG3(r) (r)->r2
#define HYPERCALL_ARG4(r) (r)->r3
#define HYPERCALL_ARG5(r) (r)->r4
#define HYPERCALL_ARGS(r) (r)->r0, (r)->r1, (r)->r2, (r)->r3, (r)->r4
#endif
static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,
unsigned long iss)
{
arm_hypercall_fn_t call = NULL;
#ifndef NDEBUG
register_t orig_pc = regs->pc;
#endif
if ( iss != XEN_HYPERCALL_TAG )
domain_crash_synchronous();
if ( *nr >= ARRAY_SIZE(arm_hypercall_table) )
{
HYPERCALL_RESULT_REG(regs) = -ENOSYS;
return;
}
call = arm_hypercall_table[*nr].fn;
if ( call == NULL )
{
HYPERCALL_RESULT_REG(regs) = -ENOSYS;
return;
}
HYPERCALL_RESULT_REG(regs) = call(HYPERCALL_ARGS(regs));
#ifndef NDEBUG
/*
* Clobber argument registers only if pc is unchanged, otherwise
* this is a hypercall continuation.
*/
if ( orig_pc == regs->pc )
{
switch ( arm_hypercall_table[*nr].nr_args ) {
case 5: HYPERCALL_ARG5(regs) = 0xDEADBEEF;
case 4: HYPERCALL_ARG4(regs) = 0xDEADBEEF;
case 3: HYPERCALL_ARG3(regs) = 0xDEADBEEF;
case 2: HYPERCALL_ARG2(regs) = 0xDEADBEEF;
case 1: /* Don't clobber x0/r0 -- it's the return value */
break;
default: BUG();
}
*nr = 0xDEADBEEF;
}
#endif
}
static bool_t check_multicall_32bit_clean(struct multicall_entry *multi)
{
int i;
for ( i = 0; i < arm_hypercall_table[multi->op].nr_args; i++ )
{
if ( unlikely(multi->args[i] & 0xffffffff00000000ULL) )
{
printk("%pv: multicall argument %d is not 32-bit clean %"PRIx64"\n",
current, i, multi->args[i]);
domain_crash(current->domain);
return false;
}
}
return true;
}
void do_multicall_call(struct multicall_entry *multi)
{
arm_hypercall_fn_t call = NULL;
if ( multi->op >= ARRAY_SIZE(arm_hypercall_table) )
{
multi->result = -ENOSYS;
return;
}
call = arm_hypercall_table[multi->op].fn;
if ( call == NULL )
{
multi->result = -ENOSYS;
return;
}
if ( is_32bit_domain(current->domain) &&
!check_multicall_32bit_clean(multi) )
return;
multi->result = call(multi->args[0], multi->args[1],
multi->args[2], multi->args[3],
multi->args[4]);
}
/*
* stolen from arch/arm/kernel/opcodes.c
*
* condition code lookup table
* index into the table is test code: EQ, NE, ... LT, GT, AL, NV
*
* bit position in short is condition code: NZCV
*/
static const unsigned short cc_map[16] = {
0xF0F0, /* EQ == Z set */
0x0F0F, /* NE */
0xCCCC, /* CS == C set */
0x3333, /* CC */
0xFF00, /* MI == N set */
0x00FF, /* PL */
0xAAAA, /* VS == V set */
0x5555, /* VC */
0x0C0C, /* HI == C set && Z clear */
0xF3F3, /* LS == C clear || Z set */
0xAA55, /* GE == (N==V) */
0x55AA, /* LT == (N!=V) */
0x0A05, /* GT == (!Z && (N==V)) */
0xF5FA, /* LE == (Z || (N!=V)) */
0xFFFF, /* AL always */
0 /* NV */
};
static int check_conditional_instr(struct cpu_user_regs *regs, union hsr hsr)
{
unsigned long cpsr, cpsr_cond;
int cond;
/* Unconditional Exception classes */
if ( hsr.ec >= 0x10 )
return 1;
/* Check for valid condition in hsr */
cond = hsr.cond.ccvalid ? hsr.cond.cc : -1;
/* Unconditional instruction */
if ( cond == 0xe )
return 1;
cpsr = regs->cpsr;
/* If cc is not valid then we need to examine the IT state */
if ( cond < 0 )
{
unsigned long it;
BUG_ON( !is_32bit_domain(current->domain) || !(cpsr&PSR_THUMB) );
it = ( (cpsr >> (10-2)) & 0xfc) | ((cpsr >> 25) & 0x3 );
/* it == 0 => unconditional. */
if ( it == 0 )
return 1;
/* The cond for this instruction works out as the top 4 bits. */
cond = ( it >> 4 );
}
cpsr_cond = cpsr >> 28;
if ( !((cc_map[cond] >> cpsr_cond) & 1) )
return 0;
return 1;
}
static void advance_pc(struct cpu_user_regs *regs, union hsr hsr)
{
unsigned long itbits, cond, cpsr = regs->cpsr;
/* PSR_IT_MASK bits can only be set for 32-bit processors in Thumb mode. */
BUG_ON( (!is_32bit_domain(current->domain)||!(cpsr&PSR_THUMB))
&& (cpsr&PSR_IT_MASK) );
if ( is_32bit_domain(current->domain) && (cpsr&PSR_IT_MASK) )
{
/* The ITSTATE[7:0] block is contained in CPSR[15:10],CPSR[26:25]
*
* ITSTATE[7:5] are the condition code
* ITSTATE[4:0] are the IT bits
*
* If the condition is non-zero then the IT state machine is
* advanced by shifting the IT bits left.
*
* See A2-51 and B1-1148 of DDI 0406C.b.
*/
cond = (cpsr & 0xe000) >> 13;
itbits = (cpsr & 0x1c00) >> (10 - 2);
itbits |= (cpsr & (0x3 << 25)) >> 25;
if ( (itbits & 0x7) == 0 )
itbits = cond = 0;
else
itbits = (itbits << 1) & 0x1f;
cpsr &= ~PSR_IT_MASK;
cpsr |= cond << 13;
cpsr |= (itbits & 0x1c) << (10 - 2);
cpsr |= (itbits & 0x3) << 25;
regs->cpsr = cpsr;
}
regs->pc += hsr.len ? 4 : 2;
}
static void do_cp15_32(struct cpu_user_regs *regs,
union hsr hsr)
{
struct hsr_cp32 cp32 = hsr.cp32;
uint32_t *r = (uint32_t*)select_user_reg(regs, cp32.reg);
struct vcpu *v = current;
if ( !check_conditional_instr(regs, hsr) )
{
advance_pc(regs, hsr);
return;
}
switch ( hsr.bits & HSR_CP32_REGS_MASK )
{
case HSR_CPREG32(CLIDR):
if ( !cp32.read )
{
dprintk(XENLOG_ERR,
"attempt to write to read-only register CLIDR\n");
domain_crash_synchronous();
}
*r = READ_SYSREG32(CLIDR_EL1);
break;
case HSR_CPREG32(CCSIDR):
if ( !cp32.read )
{
dprintk(XENLOG_ERR,
"attempt to write to read-only register CCSIDR\n");
domain_crash_synchronous();
}
*r = READ_SYSREG32(CCSIDR_EL1);
break;
case HSR_CPREG32(DCCISW):
if ( cp32.read )
{
dprintk(XENLOG_ERR,
"attempt to read from write-only register DCCISW\n");
domain_crash_synchronous();
}
#ifdef CONFIG_ARM_32
WRITE_CP32(*r, DCCISW);
#else
asm volatile("dc cisw, %0;" : : "r" (*r) : "memory");
#endif
break;
case HSR_CPREG32(CNTP_CTL):
case HSR_CPREG32(CNTP_TVAL):
if ( !vtimer_emulate(regs, hsr) )
{
dprintk(XENLOG_ERR,
"failed emulation of 32-bit vtimer CP register access\n");
domain_crash_synchronous();
}
break;
case HSR_CPREG32(ACTLR):
if ( cp32.read )
*r = v->arch.actlr;
break;
/* We could trap ID_DFR0 and tell the guest we don't support
* performance monitoring, but Linux doesn't check the ID_DFR0.
* Therefore it will read PMCR.
*
* We tell the guest we have 0 counters. Unfortunately we must
* always support PMCCNTR (the cyle counter): we just RAZ/WI for all
* PM register, which doesn't crash the kernel at least
*/
case HSR_CPREG32(PMCR):
case HSR_CPREG32(PMCNTENSET):
case HSR_CPREG32(PMCNTENCLR):
case HSR_CPREG32(PMOVSR):
case HSR_CPREG32(PMSWINC):
case HSR_CPREG32(PMSELR):
case HSR_CPREG32(PMCEID0):
case HSR_CPREG32(PMCEID1):
case HSR_CPREG32(PMCCNTR):
case HSR_CPREG32(PMXEVCNTR):
case HSR_CPREG32(PMXEVCNR):
case HSR_CPREG32(PMUSERENR):
case HSR_CPREG32(PMINTENSET):
case HSR_CPREG32(PMINTENCLR):
case HSR_CPREG32(PMOVSSET):
if ( cp32.read )
*r = 0;
break;
default:
#ifndef NDEBUG
gdprintk(XENLOG_ERR,
"%s p15, %d, r%d, cr%d, cr%d, %d @ 0x%"PRIregister"\n",
cp32.read ? "mrc" : "mcr",
cp32.op1, cp32.reg, cp32.crn, cp32.crm, cp32.op2, regs->pc);
gdprintk(XENLOG_ERR, "unhandled 32-bit CP15 access %#x\n",
hsr.bits & HSR_CP32_REGS_MASK);
#endif
inject_undef_exception(regs, hsr.len);
return;
}
advance_pc(regs, hsr);
}
static void do_cp15_64(struct cpu_user_regs *regs,
union hsr hsr)
{
if ( !check_conditional_instr(regs, hsr) )
{
advance_pc(regs, hsr);
return;
}
switch ( hsr.bits & HSR_CP64_REGS_MASK )
{
case HSR_CPREG64(CNTPCT):
if ( !vtimer_emulate(regs, hsr) )
{
dprintk(XENLOG_ERR,
"failed emulation of 64-bit vtimer CP register access\n");
domain_crash_synchronous();
}
break;
default:
{
#ifndef NDEBUG
struct hsr_cp64 cp64 = hsr.cp64;
gdprintk(XENLOG_ERR,
"%s p15, %d, r%d, r%d, cr%d @ 0x%"PRIregister"\n",
cp64.read ? "mrrc" : "mcrr",
cp64.op1, cp64.reg1, cp64.reg2, cp64.crm, regs->pc);
gdprintk(XENLOG_ERR, "unhandled 64-bit CP15 access %#x\n",
hsr.bits & HSR_CP64_REGS_MASK);
#endif
inject_undef_exception(regs, hsr.len);
return;
}
}
advance_pc(regs, hsr);
}
static void do_cp14_32(struct cpu_user_regs *regs, union hsr hsr)
{
struct hsr_cp32 cp32 = hsr.cp32;
uint32_t *r = (uint32_t *)select_user_reg(regs, cp32.reg);
struct domain *d = current->domain;
if ( !check_conditional_instr(regs, hsr) )
{
advance_pc(regs, hsr);
return;
}
switch ( hsr.bits & HSR_CP32_REGS_MASK )
{
case HSR_CPREG32(DBGDIDR):
/* Read-only register */
if ( !cp32.read )
goto bad_cp;
/* Implement the minimum requirements:
* - Number of watchpoints: 1
* - Number of breakpoints: 2
* - Version: ARMv7 v7.1
* - Variant and Revision bits match MDIR
*/
*r = (1 << 24) | (5 << 16);
*r |= ((d->arch.vpidr >> 20) & 0xf) | (d->arch.vpidr & 0xf);
break;
case HSR_CPREG32(DBGDSCRINT):
case HSR_CPREG32(DBGDSCREXT):
/* Implement debug status and control register as RAZ/WI.
* The OS won't use Hardware debug if MDBGen not set
*/
if ( cp32.read )
*r = 0;
break;
case HSR_CPREG32(DBGVCR):
case HSR_CPREG32(DBGOSLAR):
case HSR_CPREG32(DBGBVR0):
case HSR_CPREG32(DBGBCR0):
case HSR_CPREG32(DBGWVR0):
case HSR_CPREG32(DBGWCR0):
case HSR_CPREG32(DBGBVR1):
case HSR_CPREG32(DBGBCR1):
case HSR_CPREG32(DBGOSDLR):
/* RAZ/WI */
if ( cp32.read )
*r = 0;
break;
default:
bad_cp:
#ifndef NDEBUG
gdprintk(XENLOG_ERR,
"%s p14, %d, r%d, cr%d, cr%d, %d @ 0x%"PRIregister"\n",
cp32.read ? "mrc" : "mcr",
cp32.op1, cp32.reg, cp32.crn, cp32.crm, cp32.op2, regs->pc);
gdprintk(XENLOG_ERR, "unhandled 32-bit cp14 access %#x\n",
hsr.bits & HSR_CP32_REGS_MASK);
#endif
inject_undef_exception(regs, hsr.len);
return;
}
advance_pc(regs, hsr);
}
static void do_cp14_dbg(struct cpu_user_regs *regs, union hsr hsr)
{
#ifndef NDEBUG
struct hsr_cp64 cp64 = hsr.cp64;
#endif
if ( !check_conditional_instr(regs, hsr) )
{
advance_pc(regs, hsr);
return;
}
#ifndef NDEBUG
gdprintk(XENLOG_ERR,
"%s p14, %d, r%d, r%d, cr%d @ 0x%"PRIregister"\n",
cp64.read ? "mrrc" : "mcrr",
cp64.op1, cp64.reg1, cp64.reg2, cp64.crm, regs->pc);
gdprintk(XENLOG_ERR, "unhandled 64-bit CP14 access %#x\n",
hsr.bits & HSR_CP64_REGS_MASK);
#endif
inject_undef_exception(regs, hsr.len);
}
static void do_cp(struct cpu_user_regs *regs, union hsr hsr)
{
#ifndef NDEBUG
struct hsr_cp cp = hsr.cp;
#endif
if ( !check_conditional_instr(regs, hsr) )
{
advance_pc(regs, hsr);
return;
}
#ifndef NDEBUG
ASSERT(!cp.tas); /* We don't trap SIMD instruction */
gdprintk(XENLOG_ERR, "unhandled CP%d access\n", cp.coproc);
#endif
inject_undef_exception(regs, hsr.len);
}
#ifdef CONFIG_ARM_64
static void do_sysreg(struct cpu_user_regs *regs,
union hsr hsr)
{
register_t *x = select_user_reg(regs, hsr.sysreg.reg);
switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
{
/* RAZ/WI registers: */
/* - Debug */
case HSR_SYSREG_MDSCR_EL1:
/* - Perf monitors */
case HSR_SYSREG_PMINTENSET_EL1:
case HSR_SYSREG_PMINTENCLR_EL1:
case HSR_SYSREG_PMCR_EL0:
case HSR_SYSREG_PMCNTENSET_EL0:
case HSR_SYSREG_PMCNTENCLR_EL0:
case HSR_SYSREG_PMOVSCLR_EL0:
case HSR_SYSREG_PMSWINC_EL0:
case HSR_SYSREG_PMSELR_EL0:
case HSR_SYSREG_PMCEID0_EL0:
case HSR_SYSREG_PMCEID1_EL0:
case HSR_SYSREG_PMCCNTR_EL0:
case HSR_SYSREG_PMXEVTYPER_EL0:
case HSR_SYSREG_PMXEVCNTR_EL0:
case HSR_SYSREG_PMUSERENR_EL0:
case HSR_SYSREG_PMOVSSET_EL0:
/* - Breakpoints */
HSR_SYSREG_DBG_CASES(DBGBVR):
HSR_SYSREG_DBG_CASES(DBGBCR):
/* - Watchpoints */
HSR_SYSREG_DBG_CASES(DBGWVR):
HSR_SYSREG_DBG_CASES(DBGWCR):
/* - Double Lock Register */
case HSR_SYSREG_OSDLR_EL1:
if ( hsr.sysreg.read )
*x = 0;
/* else: write ignored */
break;
/* Write only, Write ignore registers: */
case HSR_SYSREG_OSLAR_EL1:
if ( hsr.sysreg.read )
goto bad_sysreg;
/* else: write ignored */
break;
case HSR_SYSREG_CNTP_CTL_EL0:
case HSR_SYSREG_CNTP_TVAL_EL0:
if ( !vtimer_emulate(regs, hsr) )
{
dprintk(XENLOG_ERR,
"failed emulation of 64-bit vtimer sysreg access\n");
domain_crash_synchronous();
}
break;
case HSR_SYSREG_ICC_SGI1R_EL1:
if ( !vgic_emulate(regs, hsr) )
{
dprintk(XENLOG_WARNING,
"failed emulation of sysreg ICC_SGI1R_EL1 access\n");
inject_undef64_exception(regs, hsr.len);
}
break;
case HSR_SYSREG_ICC_SGI0R_EL1:
case HSR_SYSREG_ICC_ASGI1R_EL1:
/* TBD: Implement to support secure grp0/1 SGI forwarding */
dprintk(XENLOG_WARNING,
"Emulation of sysreg ICC_SGI0R_EL1/ASGI1R_EL1 not supported\n");
inject_undef64_exception(regs, hsr.len);
default:
bad_sysreg:
{
struct hsr_sysreg sysreg = hsr.sysreg;
#ifndef NDEBUG
gdprintk(XENLOG_ERR,
"%s %d, %d, c%d, c%d, %d %s x%d @ 0x%"PRIregister"\n",
sysreg.read ? "mrs" : "msr",
sysreg.op0, sysreg.op1,
sysreg.crn, sysreg.crm,
sysreg.op2,
sysreg.read ? "=>" : "<=",
sysreg.reg, regs->pc);
gdprintk(XENLOG_ERR, "unhandled 64-bit sysreg access %#x\n",
hsr.bits & HSR_SYSREG_REGS_MASK);
#endif
inject_undef_exception(regs, sysreg.len);
return;
}
}
regs->pc += 4;
}
#endif
void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
{
register_t ttbcr = READ_SYSREG(TCR_EL1);
uint64_t ttbr0 = READ_SYSREG64(TTBR0_EL1);
paddr_t paddr;
uint32_t offset;
uint32_t *first = NULL, *second = NULL;
printk("dom%d VA 0x%08"PRIvaddr"\n", d->domain_id, addr);
printk(" TTBCR: 0x%08"PRIregister"\n", ttbcr);
printk(" TTBR0: 0x%016"PRIx64" = 0x%"PRIpaddr"\n",
ttbr0, p2m_lookup(d, ttbr0 & PAGE_MASK, NULL));
if ( ttbcr & TTBCR_EAE )
{
printk("Cannot handle LPAE guest PT walk\n");
return;
}
if ( (ttbcr & TTBCR_N_MASK) != 0 )
{
printk("Cannot handle TTBR1 guest walks\n");
return;
}
paddr = p2m_lookup(d, ttbr0 & PAGE_MASK, NULL);
if ( paddr == INVALID_PADDR )
{
printk("Failed TTBR0 maddr lookup\n");
goto done;
}
first = map_domain_page(paddr>>PAGE_SHIFT);
offset = addr >> (12+10);
printk("1ST[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n",
offset, paddr, first[offset]);
if ( !(first[offset] & 0x1) ||
!(first[offset] & 0x2) )
goto done;
paddr = p2m_lookup(d, first[offset] & PAGE_MASK, NULL);
if ( paddr == INVALID_PADDR )
{
printk("Failed L1 entry maddr lookup\n");
goto done;
}
second = map_domain_page(paddr>>PAGE_SHIFT);
offset = (addr >> 12) & 0x3FF;
printk("2ND[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n",
offset, paddr, second[offset]);
done:
if (second) unmap_domain_page(second);
if (first) unmap_domain_page(first);
}
static void do_trap_instr_abort_guest(struct cpu_user_regs *regs,
union hsr hsr)
{
register_t addr = READ_SYSREG(FAR_EL2);
inject_iabt_exception(regs, addr, hsr.len);
}
static void do_trap_data_abort_guest(struct cpu_user_regs *regs,
union hsr hsr)
{
struct hsr_dabt dabt = hsr.dabt;
int rc;
mmio_info_t info;
if ( !check_conditional_instr(regs, hsr) )
{
advance_pc(regs, hsr);
return;
}
info.dabt = dabt;
#ifdef CONFIG_ARM_32
info.gva = READ_CP32(HDFAR);
#else
info.gva = READ_SYSREG64(FAR_EL2);
#endif
if (dabt.s1ptw)
goto bad_data_abort;
rc = gva_to_ipa(info.gva, &info.gpa);
if ( rc == -EFAULT )
goto bad_data_abort;
/* XXX: Decode the instruction if ISS is not valid */
if ( !dabt.valid )
goto bad_data_abort;
/*
* Erratum 766422: Thumb store translation fault to Hypervisor may
* not have correct HSR Rt value.
*/
if ( cpu_has_erratum_766422() && (regs->cpsr & PSR_THUMB) && dabt.write )
{
rc = decode_instruction(regs, &info.dabt);
if ( rc )
{
gdprintk(XENLOG_DEBUG, "Unable to decode instruction\n");
goto bad_data_abort;
}
}
if (handle_mmio(&info))
{
advance_pc(regs, hsr);
return;
}
bad_data_abort:
inject_dabt_exception(regs, info.gva, hsr.len);
}
static void enter_hypervisor_head(struct cpu_user_regs *regs)
{
if ( guest_mode(regs) )
gic_clear_lrs(current);
}
asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
{
union hsr hsr = { .bits = READ_SYSREG32(ESR_EL2) };
enter_hypervisor_head(regs);
/*
* We currently do not handle 32-bit userspace on 64-bit kernels
* correctly (See XSA-102). Until that is resolved we treat any
* trap from 32-bit userspace on 64-bit kernel as undefined.
*/
if ( !hyp_mode(regs) && is_64bit_domain(current->domain) &&
psr_mode_is_32bit(regs->cpsr) )
{
inject_undef_exception(regs, hsr.len);
return;
}
switch (hsr.ec) {
case HSR_EC_WFI_WFE:
if ( !check_conditional_instr(regs, hsr) )
{
advance_pc(regs, hsr);
return;
}
if ( hsr.wfi_wfe.ti ) {
/* Yield the VCPU for WFE */
vcpu_yield();
} else {
/* Block the VCPU for WFI */
vcpu_block_unless_event_pending(current);
}
advance_pc(regs, hsr);
break;
case HSR_EC_CP15_32:
if ( !is_32bit_domain(current->domain) )
goto bad_trap;
do_cp15_32(regs, hsr);
break;
case HSR_EC_CP15_64:
if ( !is_32bit_domain(current->domain) )
goto bad_trap;
do_cp15_64(regs, hsr);
break;
case HSR_EC_CP14_32:
if ( !is_32bit_domain(current->domain) )
goto bad_trap;
do_cp14_32(regs, hsr);
break;
case HSR_EC_CP14_DBG:
if ( !is_32bit_domain(current->domain) )
goto bad_trap;
do_cp14_dbg(regs, hsr);
break;
case HSR_EC_CP:
if ( !is_32bit_domain(current->domain) )
goto bad_trap;
do_cp(regs, hsr);
break;
case HSR_EC_SMC32:
inject_undef32_exception(regs);
break;
case HSR_EC_HVC32:
#ifndef NDEBUG
if ( (hsr.iss & 0xff00) == 0xff00 )
return do_debug_trap(regs, hsr.iss & 0x00ff);
#endif
if ( hsr.iss == 0 )
return do_trap_psci(regs);
do_trap_hypercall(regs, (register_t *)®s->r12, hsr.iss);
break;
#ifdef CONFIG_ARM_64
case HSR_EC_HVC64:
#ifndef NDEBUG
if ( (hsr.iss & 0xff00) == 0xff00 )
return do_debug_trap(regs, hsr.iss & 0x00ff);
#endif
if ( hsr.iss == 0 )
return do_trap_psci(regs);
do_trap_hypercall(regs, ®s->x16, hsr.iss);
break;
case HSR_EC_SMC64:
inject_undef64_exception(regs, hsr.len);
break;
case HSR_EC_SYSREG:
if ( is_32bit_domain(current->domain) )
goto bad_trap;
do_sysreg(regs, hsr);
break;
#endif
case HSR_EC_INSTR_ABORT_LOWER_EL:
do_trap_instr_abort_guest(regs, hsr);
break;
case HSR_EC_DATA_ABORT_LOWER_EL:
do_trap_data_abort_guest(regs, hsr);
break;
#ifdef CONFIG_ARM_64
case HSR_EC_BRK:
do_trap_brk(regs, hsr);
break;
#endif
default:
bad_trap:
printk("Hypervisor Trap. HSR=0x%x EC=0x%x IL=%x Syndrome=0x%"PRIx32"\n",
hsr.bits, hsr.ec, hsr.len, hsr.iss);
do_unexpected_trap("Hypervisor", regs);
}
}
asmlinkage void do_trap_irq(struct cpu_user_regs *regs)
{
enter_hypervisor_head(regs);
gic_interrupt(regs, 0);
}
asmlinkage void do_trap_fiq(struct cpu_user_regs *regs)
{
enter_hypervisor_head(regs);
gic_interrupt(regs, 1);
}
asmlinkage void leave_hypervisor_tail(void)
{
while (1)
{
local_irq_disable();
if (!softirq_pending(smp_processor_id())) {
gic_inject();
return;
}
local_irq_enable();
do_softirq();
}
}
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
|
nypdmax/NUMA
|
xen/arch/arm/traps.c
|
C
|
gpl-2.0
| 62,346 |
/**
* PS Move API - An interface for the PS Move Motion Controller
* Copyright (c) 2012 Thomas Perl <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 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 HOLDER 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.
**/
#ifndef PSMOVE_CONFIG_H
#define PSMOVE_CONFIG_H
/* This file is auto-generated from psmove_config.h.in by CMake */
#define PSMOVE_BUILD_TRACKER
#define PSMOVE_USE_PSEYE
/* #undef PSMOVE_USE_TRACKER_TRACE */
#endif
|
tamarmstrong/psmove-ue4
|
ThirdParty/psmoveapi/include/psmove_config.h
|
C
|
gpl-2.0
| 1,724 |
# QR8
##Understanding the schema
qnote
.q#[base 64 sha hash]
When link with another folder the "q hash" is unhidden.
q#[base 64 sha hash]
|
Tertioptus/doc
|
README.md
|
Markdown
|
gpl-2.0
| 141 |
// Copyright 2003 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <EGL/egl.h>
#include <android/log.h>
#include <android/native_window_jni.h>
#include <cinttypes>
#include <cstdio>
#include <cstdlib>
#include <jni.h>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include "ButtonManager.h"
#include "Common/CPUDetect.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/Event.h"
#include "Common/FileUtil.h"
#include "Common/GL/GLInterfaceBase.h"
#include "Common/Logging/LogManager.h"
#include "Common/MsgHandler.h"
#include "Core/Boot/Boot.h"
#include "Core/BootManager.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Core/Host.h"
#include "Core/PowerPC/JitInterface.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/PowerPC/Profiler.h"
#include "Core/State.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
#include "UICommon/UICommon.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoBackendBase.h"
#define DOLPHIN_TAG "DolphinEmuNative"
JavaVM* g_java_vm;
namespace
{
ANativeWindow* s_surf;
std::string s_filename;
std::string s_set_userpath;
jclass s_jni_class;
jmethodID s_jni_method_alert;
jmethodID s_jni_method_end;
// The Core only supports using a single Host thread.
// If multiple threads want to call host functions then they need to queue
// sequentially for access.
std::mutex s_host_identity_lock;
Common::Event s_update_main_frame_event;
bool s_have_wm_user_stop = false;
} // Anonymous namespace
/*
* Cache the JavaVM so that we can call into it later.
*/
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
g_java_vm = vm;
return JNI_VERSION_1_6;
}
void Host_NotifyMapLoaded()
{
}
void Host_RefreshDSPDebuggerWindow()
{
}
void Host_Message(int Id)
{
if (Id == WM_USER_JOB_DISPATCH)
{
s_update_main_frame_event.Set();
}
else if (Id == WM_USER_STOP)
{
s_have_wm_user_stop = true;
if (Core::IsRunning())
Core::QueueHostJob(&Core::Stop);
}
}
void* Host_GetRenderHandle()
{
return s_surf;
}
void Host_UpdateTitle(const std::string& title)
{
__android_log_write(ANDROID_LOG_INFO, DOLPHIN_TAG, title.c_str());
}
void Host_UpdateDisasmDialog()
{
}
void Host_UpdateMainFrame()
{
}
void Host_RequestRenderWindowSize(int width, int height)
{
}
void Host_SetStartupDebuggingParameters()
{
}
bool Host_UIHasFocus()
{
return true;
}
bool Host_RendererHasFocus()
{
return true;
}
bool Host_RendererIsFullscreen()
{
return false;
}
void Host_ConnectWiimote(int wm_idx, bool connect)
{
}
void Host_SetWiiMoteConnectionState(int _State)
{
}
void Host_ShowVideoConfig(void*, const std::string&)
{
}
void Host_YieldToUI()
{
}
static bool MsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
{
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "%s:%s", caption, text);
// Associate the current Thread with the Java VM.
JNIEnv* env;
g_java_vm->AttachCurrentThread(&env, NULL);
// Execute the Java method.
env->CallStaticVoidMethod(s_jni_class, s_jni_method_alert, env->NewStringUTF(text));
// Must be called before the current thread exits; might as well do it here.
g_java_vm->DetachCurrentThread();
return false;
}
#define DVD_BANNER_WIDTH 96
#define DVD_BANNER_HEIGHT 32
static inline u32 Average32(u32 a, u32 b)
{
return ((a >> 1) & 0x7f7f7f7f) + ((b >> 1) & 0x7f7f7f7f);
}
static inline u32 GetPixel(u32* buffer, unsigned int x, unsigned int y)
{
// thanks to unsignedness, these also check for <0 automatically.
if (x > 191)
return 0;
if (y > 63)
return 0;
return buffer[y * 192 + x];
}
static bool LoadBanner(std::string filename, u32* Banner)
{
std::unique_ptr<DiscIO::Volume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
if (pVolume != nullptr)
{
int Width, Height;
std::vector<u32> BannerVec = pVolume->GetBanner(&Width, &Height);
// This code (along with above inlines) is moved from
// elsewhere. Someone who knows anything about Android
// please get rid of it and use proper high-resolution
// images.
if (Height == 64 && Width == 192)
{
u32* Buffer = &BannerVec[0];
for (int y = 0; y < 32; y++)
{
for (int x = 0; x < 96; x++)
{
// simplified plus-shaped "gaussian"
u32 surround = Average32(
Average32(GetPixel(Buffer, x * 2 - 1, y * 2), GetPixel(Buffer, x * 2 + 1, y * 2)),
Average32(GetPixel(Buffer, x * 2, y * 2 - 1), GetPixel(Buffer, x * 2, y * 2 + 1)));
Banner[y * 96 + x] = Average32(GetPixel(Buffer, x * 2, y * 2), surround);
}
}
return true;
}
else if (Height == 32 && Width == 96)
{
memcpy(Banner, &BannerVec[0], 96 * 32 * 4);
return true;
}
}
return false;
}
static int GetCountry(std::string filename)
{
std::unique_ptr<DiscIO::Volume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
if (pVolume != nullptr)
{
int country = static_cast<int>(pVolume->GetCountry());
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Country Code: %i", country);
return country;
}
return static_cast<int>(DiscIO::Country::COUNTRY_UNKNOWN);
}
static int GetPlatform(std::string filename)
{
std::unique_ptr<DiscIO::Volume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
if (pVolume != nullptr)
{
switch (pVolume->GetVolumeType())
{
case DiscIO::Platform::GAMECUBE_DISC:
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Volume is a GameCube disc.");
return 0;
case DiscIO::Platform::WII_DISC:
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Volume is a Wii disc.");
return 1;
case DiscIO::Platform::WII_WAD:
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Volume is a Wii WAD.");
return 2;
}
}
return -1;
}
static std::string GetTitle(std::string filename)
{
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Title for file: %s",
filename.c_str());
std::unique_ptr<DiscIO::Volume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
if (pVolume != nullptr)
{
std::map<DiscIO::Language, std::string> titles = pVolume->GetLongNames();
if (titles.empty())
titles = pVolume->GetShortNames();
/*
bool is_wii_title = pVolume->GetVolumeType() != DiscIO::Platform::GAMECUBE_DISC;
DiscIO::Language language = SConfig::GetInstance().GetCurrentLanguage(is_wii_title);
auto it = titles.find(language);
if (it != end)
return it->second;*/
auto end = titles.end();
// English tends to be a good fallback when the requested language isn't available
// if (language != DiscIO::Language::LANGUAGE_ENGLISH) {
auto it = titles.find(DiscIO::Language::LANGUAGE_ENGLISH);
if (it != end)
return it->second;
//}
// If English isn't available either, just pick something
if (!titles.empty())
return titles.cbegin()->second;
// No usable name, return filename (better than nothing)
std::string name;
SplitPath(filename, nullptr, &name, nullptr);
return name;
}
return std::string("");
}
static std::string GetDescription(std::string filename)
{
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Description for file: %s",
filename.c_str());
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolumeFromFilename(filename));
if (volume != nullptr)
{
std::map<DiscIO::Language, std::string> descriptions = volume->GetDescriptions();
/*
bool is_wii_title = pVolume->GetVolumeType() != DiscIO::Platform::GAMECUBE_DISC;
DiscIO::Language language = SConfig::GetInstance().GetCurrentLanguage(is_wii_title);
auto it = descriptions.find(language);
if (it != end)
return it->second;*/
auto end = descriptions.end();
// English tends to be a good fallback when the requested language isn't available
// if (language != DiscIO::Language::LANGUAGE_ENGLISH) {
auto it = descriptions.find(DiscIO::Language::LANGUAGE_ENGLISH);
if (it != end)
return it->second;
//}
// If English isn't available either, just pick something
if (!descriptions.empty())
return descriptions.cbegin()->second;
}
return std::string();
}
static std::string GetGameId(std::string filename)
{
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting ID for file: %s", filename.c_str());
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolumeFromFilename(filename));
if (volume == nullptr)
return std::string();
std::string id = volume->GetGameID();
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Game ID: %s", id.c_str());
return id;
}
static std::string GetCompany(std::string filename)
{
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Company for file: %s",
filename.c_str());
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolumeFromFilename(filename));
if (volume == nullptr)
return std::string();
std::string company = DiscIO::GetCompanyFromID(volume->GetMakerID());
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Company: %s", company.c_str());
return company;
}
static u64 GetFileSize(std::string filename)
{
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting size of file: %s", filename.c_str());
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolumeFromFilename(filename));
if (volume == nullptr)
return -1;
u64 size = volume->GetSize();
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Size: %" PRIu64, size);
return size;
}
static std::string GetJString(JNIEnv* env, jstring jstr)
{
std::string result = "";
if (!jstr)
return result;
const char* s = env->GetStringUTFChars(jstr, nullptr);
result = s;
env->ReleaseStringUTFChars(jstr, s);
return result;
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv* env,
jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv* env,
jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv* env,
jobject obj);
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
JNIEnv* env, jobject obj, jstring jDevice, jint Button, jint Action);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
JNIEnv* env, jobject obj, jstring jDevice, jint Axis, jfloat Value);
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv* env,
jobject obj,
jstring jFile);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv* env,
jobject obj,
jstring jFilename);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDescription(
JNIEnv* env, jobject obj, jstring jFilename);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameId(JNIEnv* env,
jobject obj,
jstring jFilename);
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCountry(JNIEnv* env,
jobject obj,
jstring jFilename);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCompany(
JNIEnv* env, jobject obj, jstring jFilename);
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetFilesize(JNIEnv* env,
jobject obj,
jstring jFilename);
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetPlatform(JNIEnv* env,
jobject obj,
jstring jFilename);
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env,
jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv* env,
jobject obj,
jint api);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv* env,
jobject obj,
jstring jFile);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv* env,
jobject obj,
jint slot);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv* env,
jobject obj,
jint slot);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CreateUserFolders(JNIEnv* env,
jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(
JNIEnv* env, jobject obj, jstring jDirectory);
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv* env, jobject obj);
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env,
jobject obj,
jboolean enable);
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env, jobject obj);
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_NativeLibrary_CacheClassesAndMethods(JNIEnv* env, jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv* env, jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChanged(JNIEnv* env,
jobject obj,
jobject surf);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv* env,
jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv* env,
jobject obj)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SetState(Core::State::Running);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv* env,
jobject obj)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SetState(Core::State::Paused);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv* env,
jobject obj)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SaveScreenShot("thumb", true);
Core::Stop();
s_update_main_frame_event.Set(); // Kick the waiting event
}
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
JNIEnv* env, jobject obj, jstring jDevice, jint Button, jint Action)
{
return ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
JNIEnv* env, jobject obj, jstring jDevice, jint Axis, jfloat Value)
{
ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
}
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv* env,
jobject obj,
jstring jFile)
{
std::string file = GetJString(env, jFile);
u32 uBanner[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
jintArray Banner = env->NewIntArray(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT);
if (LoadBanner(file, uBanner))
{
env->SetIntArrayRegion(Banner, 0, DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT, (jint*)uBanner);
}
return Banner;
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv* env,
jobject obj,
jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
std::string name = GetTitle(filename);
return env->NewStringUTF(name.c_str());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDescription(
JNIEnv* env, jobject obj, jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
std::string description = GetDescription(filename);
return env->NewStringUTF(description.c_str());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameId(JNIEnv* env,
jobject obj,
jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
std::string id = GetGameId(filename);
return env->NewStringUTF(id.c_str());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCompany(JNIEnv* env,
jobject obj,
jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
std::string company = GetCompany(filename);
return env->NewStringUTF(company.c_str());
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCountry(JNIEnv* env,
jobject obj,
jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
int country = GetCountry(filename);
return country;
}
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetFilesize(JNIEnv* env,
jobject obj,
jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
u64 size = GetFileSize(filename);
return size;
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetPlatform(JNIEnv* env,
jobject obj,
jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
int platform = GetPlatform(filename);
return platform;
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
jobject obj)
{
return env->NewStringUTF(scm_rev_str.c_str());
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env,
jobject obj)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SaveScreenShot();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv* env,
jobject obj,
jint api)
{
eglBindAPI(api);
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault)
{
IniFile ini;
std::string file = GetJString(env, jFile);
std::string section = GetJString(env, jSection);
std::string key = GetJString(env, jKey);
std::string defaultValue = GetJString(env, jDefault);
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
std::string value;
ini.GetOrCreateSection(section)->Get(key, &value, defaultValue);
return env->NewStringUTF(value.c_str());
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue)
{
IniFile ini;
std::string file = GetJString(env, jFile);
std::string section = GetJString(env, jSection);
std::string key = GetJString(env, jKey);
std::string value = GetJString(env, jValue);
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
ini.GetOrCreateSection(section)->Set(key, value);
ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv* env,
jobject obj,
jstring jFile)
{
s_filename = GetJString(env, jFile);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv* env,
jobject obj,
jint slot)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
State::Save(slot);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv* env,
jobject obj,
jint slot)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
State::Load(slot);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CreateUserFolders(JNIEnv* env,
jobject obj)
{
File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
File::CreateFullPath(File::GetUserPath(D_WIIROOT_IDX) + DIR_SEP WII_WC24CONF_DIR DIR_SEP
"mbox" DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_WIIROOT_IDX) + DIR_SEP "shared2" DIR_SEP
"succession" DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_WIIROOT_IDX) + DIR_SEP "shared2" DIR_SEP "ec" DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_WIIROOT_IDX) + DIR_SEP WII_SYSCONF_DIR DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX) + "Anaglyph" DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(
JNIEnv* env, jobject obj, jstring jDirectory)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
std::string directory = GetJString(env, jDirectory);
s_set_userpath = directory;
UICommon::SetUserDirectory(directory);
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv* env,
jobject obj)
{
return env->NewStringUTF(File::GetUserPath(D_USER_IDX).c_str());
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
jobject obj)
{
return PowerPC::DefaultCPUCore();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env,
jobject obj,
jboolean enable)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SetState(Core::State::Paused);
JitInterface::ClearCache();
Profiler::g_ProfileBlocks = enable;
Core::SetState(Core::State::Running);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env,
jobject obj)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt";
File::CreateFullPath(filename);
JitInterface::WriteProfileResults(filename);
}
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_NativeLibrary_CacheClassesAndMethods(JNIEnv* env, jobject obj)
{
// This class reference is only valid for the lifetime of this method.
jclass localClass = env->FindClass("org/dolphinemu/dolphinemu/NativeLibrary");
// This reference, however, is valid until we delete it.
s_jni_class = reinterpret_cast<jclass>(env->NewGlobalRef(localClass));
// TODO Find a place for this.
// So we don't leak a reference to NativeLibrary.class.
// env->DeleteGlobalRef(s_jni_class);
// Method signature taken from javap -s
// Source/Android/app/build/intermediates/classes/arm/debug/org/dolphinemu/dolphinemu/NativeLibrary.class
s_jni_method_alert =
env->GetStaticMethodID(s_jni_class, "displayAlertMsg", "(Ljava/lang/String;)V");
s_jni_method_end = env->GetStaticMethodID(s_jni_class, "endEmulationActivity", "()V");
}
// Surface Handling
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChanged(JNIEnv* env,
jobject obj,
jobject surf)
{
s_surf = ANativeWindow_fromSurface(env, surf);
if (s_surf == nullptr)
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "Error: Surface is null.");
if (g_renderer)
g_renderer->ChangeSurface(s_surf);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv* env,
jobject obj)
{
if (g_renderer)
g_renderer->ChangeSurface(nullptr);
if (s_surf)
{
ANativeWindow_release(s_surf);
s_surf = nullptr;
}
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimotes(JNIEnv* env,
jobject obj)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
WiimoteReal::Refresh();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv* env, jobject obj)
{
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", s_filename.c_str());
// Install our callbacks
OSD::AddCallback(OSD::CallbackType::Initialization, ButtonManager::Init);
OSD::AddCallback(OSD::CallbackType::Shutdown, ButtonManager::Shutdown);
RegisterMsgAlertHandler(&MsgAlert);
std::unique_lock<std::mutex> guard(s_host_identity_lock);
UICommon::SetUserDirectory(s_set_userpath);
UICommon::Init();
WiimoteReal::InitAdapterClass();
// No use running the loop when booting fails
s_have_wm_user_stop = false;
if (BootManager::BootCore(BootParameters::GenerateFromFile(s_filename)))
{
static constexpr int TIMEOUT = 10000;
static constexpr int WAIT_STEP = 25;
int time_waited = 0;
// A Core::CORE_ERROR state would be helpful here.
while (!Core::IsRunning() && time_waited < TIMEOUT && !s_have_wm_user_stop)
{
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP));
time_waited += WAIT_STEP;
}
while (Core::IsRunning())
{
guard.unlock();
s_update_main_frame_event.Wait();
guard.lock();
Core::HostDispatchJobs();
}
}
Core::Shutdown();
UICommon::Shutdown();
guard.unlock();
if (s_surf)
{
ANativeWindow_release(s_surf);
s_surf = nullptr;
}
// Execute the Java method.
env->CallStaticVoidMethod(s_jni_class, s_jni_method_end);
}
#ifdef __cplusplus
}
#endif
|
nitrousox1de/dolphin
|
Source/Android/jni/MainAndroid.cpp
|
C++
|
gpl-2.0
| 31,240 |
<?php
class TFuse_Widget_Pages extends WP_Widget {
function TFuse_Widget_Pages() {
$widget_ops = array('classname' => 'widget_pages', 'description' => __( 'Your site’s WordPress Pages','tfuse') );
$this->WP_Widget('pages', __('TFuse Pages','tfuse'), $widget_ops);
}
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages','tfuse') : $instance['title'], $instance, $this->id_base);
$sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
$out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude, 'link_before' => '<span>','link_after' => '</span>') ) );
if ( !empty( $out ) ) {
echo '<div class="widget-container widget_pages">';
$title = tfuse_qtranslate($title);
if ( $title)
echo '<h3 class="widget-title">' . $title . '</h3>';
?>
<ul>
<?php echo $out; ?>
</ul>
<?php
echo '</div>';
}
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = $new_instance['title'];
if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
$instance['sortby'] = $new_instance['sortby'];
} else {
$instance['sortby'] = 'menu_order';
}
$instance['exclude'] = $new_instance['exclude'];
return $instance;
}
function form( $instance ) {
//Defaults
$instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );
$title = esc_attr( $instance['title'] );
$exclude = esc_attr( $instance['exclude'] );
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','tfuse'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
<p>
<label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:','tfuse' ); ?></label>
<select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">
<option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title','tfuse'); ?></option>
<option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order','tfuse'); ?></option>
<option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ,'tfuse'); ?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:','tfuse' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />
<br />
<small><?php _e( 'Page IDs, separated by commas.','tfuse' ); ?></small>
</p>
<?php
}
}
function TFuse_Unregister_WP_Widget_Pages() {
unregister_widget('WP_Widget_Pages');
}
add_action('widgets_init','TFuse_Unregister_WP_Widget_Pages');
register_widget('TFuse_Widget_Pages');
|
reginas/callan-consulting
|
wp-content/themes/interakt-parent/theme_config/widgets/TFuse_Widget_Pages.php
|
PHP
|
gpl-2.0
| 3,345 |
// ReSharper disable All
/********************************************************************************
Copyright (C) MixERP Inc. (http://mixof.org).
This file is part of MixERP.
MixERP 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.
MixERP 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 MixERP. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************************/
using MixERP.Net.DbFactory;
using MixERP.Net.Framework;
using PetaPoco;
using MixERP.Net.Entities.Core;
using Npgsql;
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MixERP.Net.Schemas.Core.Data
{
/// <summary>
/// Prepares, validates, and executes the function "core.get_frequency_setup_end_date_by_frequency_setup_id(_frequency_setup_id integer)" on the database.
/// </summary>
public class GetFrequencySetupEndDateByFrequencySetupIdProcedure : DbAccess
{
/// <summary>
/// The schema of this PostgreSQL function.
/// </summary>
public override string _ObjectNamespace => "core";
/// <summary>
/// The schema unqualified name of this PostgreSQL function.
/// </summary>
public override string _ObjectName => "get_frequency_setup_end_date_by_frequency_setup_id";
/// <summary>
/// Login id of application user accessing this PostgreSQL function.
/// </summary>
public long _LoginId { get; set; }
/// <summary>
/// User id of application user accessing this table.
/// </summary>
public int _UserId { get; set; }
/// <summary>
/// The name of the database on which queries are being executed to.
/// </summary>
public string _Catalog { get; set; }
/// <summary>
/// Maps to "_frequency_setup_id" argument of the function "core.get_frequency_setup_end_date_by_frequency_setup_id".
/// </summary>
public int FrequencySetupId { get; set; }
/// <summary>
/// Prepares, validates, and executes the function "core.get_frequency_setup_end_date_by_frequency_setup_id(_frequency_setup_id integer)" on the database.
/// </summary>
public GetFrequencySetupEndDateByFrequencySetupIdProcedure()
{
}
/// <summary>
/// Prepares, validates, and executes the function "core.get_frequency_setup_end_date_by_frequency_setup_id(_frequency_setup_id integer)" on the database.
/// </summary>
/// <param name="frequencySetupId">Enter argument value for "_frequency_setup_id" parameter of the function "core.get_frequency_setup_end_date_by_frequency_setup_id".</param>
public GetFrequencySetupEndDateByFrequencySetupIdProcedure(int frequencySetupId)
{
this.FrequencySetupId = frequencySetupId;
}
/// <summary>
/// Prepares and executes the function "core.get_frequency_setup_end_date_by_frequency_setup_id".
/// </summary>
public DateTime Execute()
{
if (!this.SkipValidation)
{
if (!this.Validated)
{
this.Validate(AccessTypeEnum.Execute, this._LoginId, false);
}
if (!this.HasAccess)
{
Log.Information("Access to the function \"GetFrequencySetupEndDateByFrequencySetupIdProcedure\" was denied to the user with Login ID {LoginId}.", this._LoginId);
throw new UnauthorizedException("Access is denied.");
}
}
const string query = "SELECT * FROM core.get_frequency_setup_end_date_by_frequency_setup_id(@0::integer);";
return Factory.Scalar<DateTime>(this._Catalog, query, this.FrequencySetupId);
}
}
}
|
njmube/mixerp
|
src/Libraries/DAL/Core/GetFrequencySetupEndDateByFrequencySetupIdProcedure.cs
|
C#
|
gpl-2.0
| 4,233 |
$preparer.add(function(context) {
$('[data-datepicker]').each(function() {
var initial = $(this).data('datepicker');
$(this).removeAttr('data-datepicker');
$(this).datepicker(initial);
});
});
|
canis-io/sensor-hub
|
src/assets/app/js/app.js
|
JavaScript
|
gpl-2.0
| 224 |
---
title: RcppHoney Introduction
author: Daniel C. Dillon
license: GPL (>= 2)
tags: sugar
summary: An overview of interoperable iterator-based containers for Rcpp
layout: post
src: 2016-07-26-rcpp-honey.Rmd
---
## Rationale
In `C++` we often have containers that are not compatible with `R` or `Rcpp`
with data already in them (`std::vector`, `std::set`, etc.). One would like
to be able to operate on these containers without having to copy them into
`Rcpp` structures like `IntegerVector`. `RcppHoney` aims to address this
problem by providing operators and functions with `R` semantics that can be
used on any iterator-based container.
## Introduction
`RcppHoney` allows any iterator-based container to be "hooked" in. Once a
container type is hooked to `RcppHoney`, it is granted operators (+, -, \*, /, etc.)
and a host of other mathematical functions that can be run on it. It also
becomes interoperable with any other hooked data structure. This lets us
write expressions that look like `std::vector + Rcpp::IntegerVector +
log(Rcpp::NumericVector)` and get the expected results.
## Implementation
`RcppHoney` has several structures that are hooked in by default. Currently
they are `std::vector`, `std::set`, and `Rcpp::VectorBase`. The ability to
hook in custom structures is also provided.
All operators and functions are implemented as
[expression templates](https://en.wikipedia.org/wiki/Expression_templates)
to minimize memory usage and enhance performance. The goal here is to only
copy the data into an `R` compatible structure when we must (i.e. when we
return it to `R`). This is achieved through the use of the `RcppHoney::operand`
class. `RcppHoney::operand` provides an iterable interface to the result
types of operators and functions.
`RcppHoney` currently provides all the basic mathematical operators (+, -, \*, /)
as well as some common
[functions](https://github.com/dcdillon/RcppHoney/blob/master/inst/include/RcppHoney/functions.hpp#L53-L112)
(abs, sin, cos, exp, etc.). Eventually all of the functionality provided by
`Rcpp::sugar` as well as anything else we can think of will be supported.
Enough about the abstract though...let's see it in action.
## Example
The following example shows how to hook in a custom data structure
(in this case `std::list`) as well as the types of expressions that can be
created once a data structure is hooked in.
{% highlight cpp %}
// [[Rcpp::depends(RcppHoney)]]
#include <RcppCommon.h>
#include <RcppHoneyForward.hpp> // we have to do this because we're going to hook in a non-default structure
#include <list>
// We have to declare our hooks before we include RcppHoney.hpp
namespace RcppHoney {
namespace hooks {
// Hook in all std::list types (could be more specific)
template< typename T, typename A >
traits::true_type is_hooked(const std::list< T, A > &val);
// Tell RcppHoney that NA has meaning in std::list
template< typename T, typename A >
traits::true_type has_na(const std::list< T, A > &val);
// Tell RcppHoney that it needs to create basic (e.g. std::list + std::list) operators
template< typename T, typename A >
traits::true_type needs_basic_operators(const std::list< T, A > &val);
// Tell RcppHoney that it needs to create scalar (e.g. std::list + int/double) operators
template< typename T, typename A >
traits::true_type needs_scalar_operators(const std::list< T, A > &val);
// Tell RcppHoney that this set of types is part of the FAMILY_USER + 1 family.
// This is used in conjunction with needs_basic_operators. If you have
// needs_basic_operators return RcppHoney::traits::false_type, then only types
// that are not part of the same family will have binary operators created
// between them.
template< typename T, typename A >
traits::int_constant< FAMILY_USER + 1 > family(const std::list< T, A > &val);
} // namespace hooks
} // namespace RcppHoney
#include <RcppHoney.hpp>
// [[Rcpp::export]]
Rcpp::NumericVector example_manually_hooked() {
// We manually hooked std::list in to RcppHoney so we'll create one
std::list< int > l;
l.push_back(1); l.push_back(2); l.push_back(3); l.push_back(4); l.push_back(5);
// std::vector is already hooked in to RcppHoney in default_hooks.hpp so we'll
// create one of those too
std::vector< int > v(l.begin(), l.end());
// And for good measure, let's create an Rcpp::NumericVector which is also hooked by default
Rcpp::NumericVector v2(v.begin(), v.end());
// Now do some weird operations incorporating std::vector, std::list, Rcpp::NumericVector
// and some RcppHoney functions and return it. The return value will be equal to the following
// R snippet:
// v <- 1:5
// result <- 42 + v + v + log(v) - v - v + sqrt(v) + -v + 42
// We can store our result in any of RcppHoney::LogicalVector, RcppHoney::IntegerVector, or
// RcppHoney::NumericVector and simply return it to R. These classes inherit from their
// Rcpp counterparts and add a new constructor. The only copy of the data, in this case, is when
// we assign our expression to retval. Since it is then a "native" R type, returning it is a
// shallow copy. Alternatively we could write this as:
// return Rcpp::wrap(1 + v + RcppHoney::log(v) - v - 1 + RcppHoney::sqrt(v) + -v2);
RcppHoney::NumericVector retval
= 42 + l + v + RcppHoney::log(v) - v - l + RcppHoney::sqrt(v) + -v2 + 42;
return retval;
}
{% endhighlight %}
## Conclusion
`RcppHoney` is a powerful tool for allowing different container types to interoperate
under `Rcpp`. It can save development time as well as help the user generate faster
and more readable code.
`RcppHoney` is available via [CRAN](http://cran.r-project.org) though as it is still
in an alpha state and changing rapidly, it is recommended that you install it from
source. Source code is available at
[github.com/dcdillon/RcppHoney](https://github.com/dcdillon/RcppHoney).
|
jjallaire/rcpp-gallery
|
_posts/2016-07-26-rcpp-honey.md
|
Markdown
|
gpl-2.0
| 5,955 |
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, 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, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ClockGeneric_h
#define ClockGeneric_h
#include "Clock.h"
namespace WebCore {
class ClockGeneric final : public Clock {
public:
ClockGeneric();
private:
virtual void setCurrentTime(double) override;
virtual double currentTime() const override;
virtual void setPlayRate(double) override;
virtual double playRate() const override { return m_rate; }
virtual void start() override;
virtual void stop() override;
virtual bool isRunning() const override { return m_running; }
double now() const;
bool m_running;
double m_rate;
double m_offset;
double m_startTime;
mutable double m_lastTime;
};
}
#endif
|
loveyoupeng/rt
|
modules/web/src/main/native/Source/WebCore/platform/ClockGeneric.h
|
C
|
gpl-2.0
| 2,023 |
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* 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.
*
*/
/*
*Author : Etaew - Fallen Realms
*Source : http://translate.google.com/translate?hl=en&sl=ja&u=http://ina.kappe.co.jp/~shouji/cgi-bin/nquest/nquest.html&prev=/search%3Fq%3DThe%2BMoonstone%2BTwin%2B(level%2B50)%26hl%3Den%26lr%3D%26safe%3Doff%26sa%3DG
*http://camelot.allakhazam.com/quests.html?realm=Hibernia&cquest=299
*Date : 22 November 2004
*Quest Name : The Moonstone Twin (level 50)
*Quest Classes : Enchanter, Bard, Champion, Nighthsade(Path of Essence)
*Quest Version : v1
*
*Done:
*
*Bonuses to epic items
*
*ToDo:
*
* Add correct Text
* Find Helm ModelID for epics..
*/
using System;
using System.Reflection;
using DOL.Database;
using DOL.Events;
using DOL.GS.PacketHandler;
using log4net;
namespace DOL.GS.Quests.Hibernia
{
public class Essence_50 : BaseQuest
{
/// <summary>
/// Defines a logger for this class.
/// </summary>
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected const string questTitle = "The Moonstone Twin";
protected const int minimumLevel = 50;
protected const int maximumLevel = 50;
private static GameNPC Brigit = null; // Start NPC
private static GameNPC Caithor = null; // Mob to kill
private static ItemTemplate Moonstone = null; //ball of flame
private static ItemTemplate ChampionEpicBoots = null; //Mist Shrouded Boots
private static ItemTemplate ChampionEpicHelm = null; //Mist Shrouded Coif
private static ItemTemplate ChampionEpicGloves = null; //Mist Shrouded Gloves
private static ItemTemplate ChampionEpicVest = null; //Mist Shrouded Hauberk
private static ItemTemplate ChampionEpicLegs = null; //Mist Shrouded Legs
private static ItemTemplate ChampionEpicArms = null; //Mist Shrouded Sleeves
private static ItemTemplate BardEpicBoots = null; //Shadow Shrouded Boots
private static ItemTemplate BardEpicHelm = null; //Shadow Shrouded Coif
private static ItemTemplate BardEpicGloves = null; //Shadow Shrouded Gloves
private static ItemTemplate BardEpicVest = null; //Shadow Shrouded Hauberk
private static ItemTemplate BardEpicLegs = null; //Shadow Shrouded Legs
private static ItemTemplate BardEpicArms = null; //Shadow Shrouded Sleeves
private static ItemTemplate EnchanterEpicBoots = null; //Valhalla Touched Boots
private static ItemTemplate EnchanterEpicHelm = null; //Valhalla Touched Coif
private static ItemTemplate EnchanterEpicGloves = null; //Valhalla Touched Gloves
private static ItemTemplate EnchanterEpicVest = null; //Valhalla Touched Hauberk
private static ItemTemplate EnchanterEpicLegs = null; //Valhalla Touched Legs
private static ItemTemplate EnchanterEpicArms = null; //Valhalla Touched Sleeves
private static ItemTemplate NightshadeEpicBoots = null; //Subterranean Boots
private static ItemTemplate NightshadeEpicHelm = null; //Subterranean Coif
private static ItemTemplate NightshadeEpicGloves = null; //Subterranean Gloves
private static ItemTemplate NightshadeEpicVest = null; //Subterranean Hauberk
private static ItemTemplate NightshadeEpicLegs = null; //Subterranean Legs
private static ItemTemplate NightshadeEpicArms = null; //Subterranean Sleeves
// Constructors
public Essence_50() : base()
{
}
public Essence_50(GamePlayer questingPlayer) : base(questingPlayer)
{
}
public Essence_50(GamePlayer questingPlayer, int step) : base(questingPlayer, step)
{
}
public Essence_50(GamePlayer questingPlayer, DBQuest dbQuest) : base(questingPlayer, dbQuest)
{
}
[ScriptLoadedEvent]
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
{
if (!ServerProperties.Properties.LOAD_QUESTS)
return;
if (log.IsInfoEnabled)
log.Info("Quest \"" + questTitle + "\" initializing ...");
#region NPC Declarations
GameNPC[] npcs = WorldMgr.GetNPCsByName("Brigit", eRealm.Hibernia);
if (npcs.Length > 0)
foreach (GameNPC npc in npcs)
if (npc.CurrentRegionID == 201 && npc.X == 32927 && npc.Y == 32743)
{
Brigit = npc;
break;
}
if (Brigit == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Brigit , creating it ...");
Brigit = new GameNPC();
Brigit.Model = 384;
Brigit.Name = "Brigit";
Brigit.GuildName = "";
Brigit.Realm = eRealm.Hibernia;
Brigit.CurrentRegionID = 201;
Brigit.Size = 51;
Brigit.Level = 50;
Brigit.X = 32927;
Brigit.Y = 32743;
Brigit.Z = 8008;
Brigit.Heading = 3254;
Brigit.AddToWorld();
if (SAVE_INTO_DATABASE)
{
Brigit.SaveIntoDatabase();
}
}
// end npc
npcs = WorldMgr.GetNPCsByName("Caithor", eRealm.None);
if (npcs.Length > 0)
foreach (GameNPC npc in npcs)
if (npc.CurrentRegionID == 200 && npc.X == 470547 && npc.Y == 531497)
{
Caithor = npc;
break;
}
if (Caithor == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Caithor , creating it ...");
Caithor = new GameNPC();
Caithor.Model = 339;
Caithor.Name = "Caithor";
Caithor.GuildName = "";
Caithor.Realm = eRealm.None;
Caithor.CurrentRegionID = 200;
Caithor.Size = 60;
Caithor.Level = 65;
Caithor.X = 470547;
Caithor.Y = 531497;
Caithor.Z = 4984;
Caithor.Heading = 3319;
Caithor.AddToWorld();
if (SAVE_INTO_DATABASE)
{
Caithor.SaveIntoDatabase();
}
}
// end npc
#endregion
#region Item Declarations
Moonstone = GameServer.Database.FindObjectByKey<ItemTemplate>("Moonstone");
if (Moonstone == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Moonstone , creating it ...");
Moonstone = new ItemTemplate();
Moonstone.Id_nb = "Moonstone";
Moonstone.Name = "Moonstone";
Moonstone.Level = 8;
Moonstone.Item_Type = 29;
Moonstone.Model = 514;
Moonstone.IsDropable = false;
Moonstone.IsPickable = false;
Moonstone.DPS_AF = 0;
Moonstone.SPD_ABS = 0;
Moonstone.Object_Type = 41;
Moonstone.Hand = 0;
Moonstone.Type_Damage = 0;
Moonstone.Quality = 100;
Moonstone.Weight = 12;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(Moonstone);
}
}
// end item
BardEpicBoots = GameServer.Database.FindObjectByKey<ItemTemplate>("BardEpicBoots");
if (BardEpicBoots == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Bards Epic Boots , creating it ...");
BardEpicBoots = new ItemTemplate();
BardEpicBoots.Id_nb = "BardEpicBoots";
BardEpicBoots.Name = "Moonsung Boots";
BardEpicBoots.Level = 50;
BardEpicBoots.Item_Type = 23;
BardEpicBoots.Model = 738;
BardEpicBoots.IsDropable = true;
BardEpicBoots.IsPickable = true;
BardEpicBoots.DPS_AF = 100;
BardEpicBoots.SPD_ABS = 19;
BardEpicBoots.Object_Type = 37;
BardEpicBoots.Quality = 100;
BardEpicBoots.Weight = 22;
BardEpicBoots.Bonus = 35;
BardEpicBoots.MaxCondition = 50000;
BardEpicBoots.MaxDurability = 50000;
BardEpicBoots.Condition = 50000;
BardEpicBoots.Durability = 50000;
BardEpicBoots.Bonus1 = 15;
BardEpicBoots.Bonus1Type = (int) eStat.QUI;
BardEpicBoots.Bonus2 = 10;
BardEpicBoots.Bonus2Type = (int) eResist.Matter;
BardEpicBoots.Bonus3 = 4;
BardEpicBoots.Bonus3Type = (int) eProperty.PowerRegenerationRate;
BardEpicBoots.Bonus4 = 33;
BardEpicBoots.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(BardEpicBoots);
}
}
//end item
//Moonsung Coif
BardEpicHelm = GameServer.Database.FindObjectByKey<ItemTemplate>("BardEpicHelm");
if (BardEpicHelm == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Bards Epic Helm , creating it ...");
BardEpicHelm = new ItemTemplate();
BardEpicHelm.Id_nb = "BardEpicHelm";
BardEpicHelm.Name = "Moonsung Coif";
BardEpicHelm.Level = 50;
BardEpicHelm.Item_Type = 21;
BardEpicHelm.Model = 1292; //NEED TO WORK ON..
BardEpicHelm.IsDropable = true;
BardEpicHelm.IsPickable = true;
BardEpicHelm.DPS_AF = 100;
BardEpicHelm.SPD_ABS = 19;
BardEpicHelm.Object_Type = 37;
BardEpicHelm.Quality = 100;
BardEpicHelm.Weight = 22;
BardEpicHelm.Bonus = 35;
BardEpicHelm.MaxCondition = 50000;
BardEpicHelm.MaxDurability = 50000;
BardEpicHelm.Condition = 50000;
BardEpicHelm.Durability = 50000;
BardEpicHelm.Bonus1 = 18;
BardEpicHelm.Bonus1Type = (int) eStat.CHR;
BardEpicHelm.Bonus2 = 4;
BardEpicHelm.Bonus2Type = (int) eProperty.PowerRegenerationRate;
BardEpicHelm.Bonus3 = 3;
BardEpicHelm.Bonus3Type = (int) eProperty.Skill_Regrowth;
BardEpicHelm.Bonus4 = 21;
BardEpicHelm.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(BardEpicHelm);
}
}
//end item
//Moonsung Gloves
BardEpicGloves = GameServer.Database.FindObjectByKey<ItemTemplate>("BardEpicGloves");
if (BardEpicGloves == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Bards Epic Gloves , creating it ...");
BardEpicGloves = new ItemTemplate();
BardEpicGloves.Id_nb = "BardEpicGloves";
BardEpicGloves.Name = "Moonsung Gloves ";
BardEpicGloves.Level = 50;
BardEpicGloves.Item_Type = 22;
BardEpicGloves.Model = 737;
BardEpicGloves.IsDropable = true;
BardEpicGloves.IsPickable = true;
BardEpicGloves.DPS_AF = 100;
BardEpicGloves.SPD_ABS = 19;
BardEpicGloves.Object_Type = 37;
BardEpicGloves.Quality = 100;
BardEpicGloves.Weight = 22;
BardEpicGloves.Bonus = 35;
BardEpicGloves.MaxCondition = 50000;
BardEpicGloves.MaxDurability = 50000;
BardEpicGloves.Condition = 50000;
BardEpicGloves.Durability = 50000;
BardEpicGloves.Bonus1 = 3;
BardEpicGloves.Bonus1Type = (int) eProperty.Skill_Nurture;
BardEpicGloves.Bonus2 = 3;
BardEpicGloves.Bonus2Type = (int) eProperty.Skill_Music;
BardEpicGloves.Bonus3 = 12;
BardEpicGloves.Bonus3Type = (int) eStat.DEX;
BardEpicGloves.Bonus4 = 33;
BardEpicGloves.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(BardEpicGloves);
}
}
//Moonsung Hauberk
BardEpicVest = GameServer.Database.FindObjectByKey<ItemTemplate>("BardEpicVest");
if (BardEpicVest == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Bards Epic Vest , creating it ...");
BardEpicVest = new ItemTemplate();
BardEpicVest.Id_nb = "BardEpicVest";
BardEpicVest.Name = "Moonsung Hauberk";
BardEpicVest.Level = 50;
BardEpicVest.Item_Type = 25;
BardEpicVest.Model = 734;
BardEpicVest.IsDropable = true;
BardEpicVest.IsPickable = true;
BardEpicVest.DPS_AF = 100;
BardEpicVest.SPD_ABS = 19;
BardEpicVest.Object_Type = 37;
BardEpicVest.Quality = 100;
BardEpicVest.Weight = 22;
BardEpicVest.Bonus = 35;
BardEpicVest.MaxCondition = 50000;
BardEpicVest.MaxDurability = 50000;
BardEpicVest.Condition = 50000;
BardEpicVest.Durability = 50000;
BardEpicVest.Bonus1 = 3;
BardEpicVest.Bonus1Type = (int) eProperty.Skill_Regrowth;
BardEpicVest.Bonus2 = 3;
BardEpicVest.Bonus2Type = (int) eProperty.Skill_Nurture;
BardEpicVest.Bonus3 = 13;
BardEpicVest.Bonus3Type = (int) eStat.CON;
BardEpicVest.Bonus4 = 15;
BardEpicVest.Bonus4Type = (int) eStat.CHR;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(BardEpicVest);
}
}
//Moonsung Legs
BardEpicLegs = GameServer.Database.FindObjectByKey<ItemTemplate>("BardEpicLegs");
if (BardEpicLegs == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Bards Epic Legs , creating it ...");
BardEpicLegs = new ItemTemplate();
BardEpicLegs.Id_nb = "BardEpicLegs";
BardEpicLegs.Name = "Moonsung Legs";
BardEpicLegs.Level = 50;
BardEpicLegs.Item_Type = 27;
BardEpicLegs.Model = 735;
BardEpicLegs.IsDropable = true;
BardEpicLegs.IsPickable = true;
BardEpicLegs.DPS_AF = 100;
BardEpicLegs.SPD_ABS = 19;
BardEpicLegs.Object_Type = 37;
BardEpicLegs.Quality = 100;
BardEpicLegs.Weight = 22;
BardEpicLegs.Bonus = 35;
BardEpicLegs.MaxCondition = 50000;
BardEpicLegs.MaxDurability = 50000;
BardEpicLegs.Condition = 50000;
BardEpicLegs.Durability = 50000;
BardEpicLegs.Bonus1 = 16;
BardEpicLegs.Bonus1Type = (int) eStat.CON;
BardEpicLegs.Bonus2 = 15;
BardEpicLegs.Bonus2Type = (int) eStat.DEX;
BardEpicLegs.Bonus3 = 10;
BardEpicLegs.Bonus3Type = (int) eResist.Body;
BardEpicLegs.Bonus4 = 10;
BardEpicLegs.Bonus4Type = (int) eResist.Matter;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(BardEpicLegs);
}
}
//Moonsung Sleeves
BardEpicArms = GameServer.Database.FindObjectByKey<ItemTemplate>("BardEpicArms");
if (BardEpicArms == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Bard Epic Arms , creating it ...");
BardEpicArms = new ItemTemplate();
BardEpicArms.Id_nb = "BardEpicArms";
BardEpicArms.Name = "Moonsung Sleeves";
BardEpicArms.Level = 50;
BardEpicArms.Item_Type = 28;
BardEpicArms.Model = 736;
BardEpicArms.IsDropable = true;
BardEpicArms.IsPickable = true;
BardEpicArms.DPS_AF = 100;
BardEpicArms.SPD_ABS = 19;
BardEpicArms.Object_Type = 37;
BardEpicArms.Quality = 100;
BardEpicArms.Weight = 22;
BardEpicArms.Bonus = 35;
BardEpicArms.MaxCondition = 50000;
BardEpicArms.MaxDurability = 50000;
BardEpicArms.Condition = 50000;
BardEpicArms.Durability = 50000;
BardEpicArms.Bonus1 = 15;
BardEpicArms.Bonus1Type = (int) eStat.STR;
BardEpicArms.Bonus2 = 12;
BardEpicArms.Bonus2Type = (int) eStat.CHR;
BardEpicArms.Bonus3 = 10;
BardEpicArms.Bonus3Type = (int) eStat.CON;
BardEpicArms.Bonus4 = 12;
BardEpicArms.Bonus4Type = (int) eResist.Energy;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(BardEpicArms);
}
}
//Champion Epic Sleeves End
ChampionEpicBoots = GameServer.Database.FindObjectByKey<ItemTemplate>("ChampionEpicBoots");
if (ChampionEpicBoots == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Champions Epic Boots , creating it ...");
ChampionEpicBoots = new ItemTemplate();
ChampionEpicBoots.Id_nb = "ChampionEpicBoots";
ChampionEpicBoots.Name = "Moonglow Boots";
ChampionEpicBoots.Level = 50;
ChampionEpicBoots.Item_Type = 23;
ChampionEpicBoots.Model = 814;
ChampionEpicBoots.IsDropable = true;
ChampionEpicBoots.IsPickable = true;
ChampionEpicBoots.DPS_AF = 100;
ChampionEpicBoots.SPD_ABS = 27;
ChampionEpicBoots.Object_Type = 38;
ChampionEpicBoots.Quality = 100;
ChampionEpicBoots.Weight = 22;
ChampionEpicBoots.Bonus = 35;
ChampionEpicBoots.MaxCondition = 50000;
ChampionEpicBoots.MaxDurability = 50000;
ChampionEpicBoots.Condition = 50000;
ChampionEpicBoots.Durability = 50000;
ChampionEpicBoots.Bonus1 = 33;
ChampionEpicBoots.Bonus1Type = (int) eProperty.MaxHealth;
ChampionEpicBoots.Bonus2 = 10;
ChampionEpicBoots.Bonus2Type = (int) eResist.Heat;
ChampionEpicBoots.Bonus3 = 10;
ChampionEpicBoots.Bonus3Type = (int) eResist.Matter;
ChampionEpicBoots.Bonus4 = 15;
ChampionEpicBoots.Bonus4Type = (int) eStat.DEX;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(ChampionEpicBoots);
}
}
//end item
//Moonglow Coif
ChampionEpicHelm = GameServer.Database.FindObjectByKey<ItemTemplate>("ChampionEpicHelm");
if (ChampionEpicHelm == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Champions Epic Helm , creating it ...");
ChampionEpicHelm = new ItemTemplate();
ChampionEpicHelm.Id_nb = "ChampionEpicHelm";
ChampionEpicHelm.Name = "Moonglow Coif";
ChampionEpicHelm.Level = 50;
ChampionEpicHelm.Item_Type = 21;
ChampionEpicHelm.Model = 1292; //NEED TO WORK ON..
ChampionEpicHelm.IsDropable = true;
ChampionEpicHelm.IsPickable = true;
ChampionEpicHelm.DPS_AF = 100;
ChampionEpicHelm.SPD_ABS = 27;
ChampionEpicHelm.Object_Type = 38;
ChampionEpicHelm.Quality = 100;
ChampionEpicHelm.Weight = 22;
ChampionEpicHelm.Bonus = 35;
ChampionEpicHelm.MaxCondition = 50000;
ChampionEpicHelm.MaxDurability = 50000;
ChampionEpicHelm.Condition = 50000;
ChampionEpicHelm.Durability = 50000;
ChampionEpicHelm.Bonus1 = 3;
ChampionEpicHelm.Bonus1Type = (int) eProperty.Skill_Valor;
ChampionEpicHelm.Bonus2 = 12;
ChampionEpicHelm.Bonus2Type = (int) eStat.CON;
ChampionEpicHelm.Bonus3 = 12;
ChampionEpicHelm.Bonus3Type = (int) eStat.QUI;
ChampionEpicHelm.Bonus4 = 6;
ChampionEpicHelm.Bonus4Type = (int) eProperty.PowerRegenerationRate;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(ChampionEpicHelm);
}
}
//end item
//Moonglow Gloves
ChampionEpicGloves = GameServer.Database.FindObjectByKey<ItemTemplate>("ChampionEpicGloves");
if (ChampionEpicGloves == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Champions Epic Gloves , creating it ...");
ChampionEpicGloves = new ItemTemplate();
ChampionEpicGloves.Id_nb = "ChampionEpicGloves";
ChampionEpicGloves.Name = "Moonglow Gloves ";
ChampionEpicGloves.Level = 50;
ChampionEpicGloves.Item_Type = 22;
ChampionEpicGloves.Model = 813;
ChampionEpicGloves.IsDropable = true;
ChampionEpicGloves.IsPickable = true;
ChampionEpicGloves.DPS_AF = 100;
ChampionEpicGloves.SPD_ABS = 27;
ChampionEpicGloves.Object_Type = 38;
ChampionEpicGloves.Quality = 100;
ChampionEpicGloves.Weight = 22;
ChampionEpicGloves.Bonus = 35;
ChampionEpicGloves.MaxCondition = 50000;
ChampionEpicGloves.MaxDurability = 50000;
ChampionEpicGloves.Condition = 50000;
ChampionEpicGloves.Durability = 50000;
ChampionEpicGloves.Bonus1 = 3;
ChampionEpicGloves.Bonus1Type = (int) eProperty.Skill_Parry;
ChampionEpicGloves.Bonus2 = 15;
ChampionEpicGloves.Bonus2Type = (int) eStat.STR;
ChampionEpicGloves.Bonus3 = 15;
ChampionEpicGloves.Bonus3Type = (int) eStat.QUI;
ChampionEpicGloves.Bonus4 = 10;
ChampionEpicGloves.Bonus4Type = (int) eResist.Crush;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(ChampionEpicGloves);
}
}
//Moonglow Hauberk
ChampionEpicVest = GameServer.Database.FindObjectByKey<ItemTemplate>("ChampionEpicVest");
if (ChampionEpicVest == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Champions Epic Vest , creating it ...");
ChampionEpicVest = new ItemTemplate();
ChampionEpicVest.Id_nb = "ChampionEpicVest";
ChampionEpicVest.Name = "Moonglow Brestplate";
ChampionEpicVest.Level = 50;
ChampionEpicVest.Item_Type = 25;
ChampionEpicVest.Model = 810;
ChampionEpicVest.IsDropable = true;
ChampionEpicVest.IsPickable = true;
ChampionEpicVest.DPS_AF = 100;
ChampionEpicVest.SPD_ABS = 27;
ChampionEpicVest.Object_Type = 38;
ChampionEpicVest.Quality = 100;
ChampionEpicVest.Weight = 22;
ChampionEpicVest.Bonus = 35;
ChampionEpicVest.MaxCondition = 50000;
ChampionEpicVest.MaxDurability = 50000;
ChampionEpicVest.Condition = 50000;
ChampionEpicVest.Durability = 50000;
ChampionEpicVest.Bonus1 = 4;
ChampionEpicVest.Bonus1Type = (int) eProperty.Skill_Valor;
ChampionEpicVest.Bonus2 = 13;
ChampionEpicVest.Bonus2Type = (int) eStat.STR;
ChampionEpicVest.Bonus3 = 13;
ChampionEpicVest.Bonus3Type = (int) eStat.QUI;
ChampionEpicVest.Bonus4 = 10;
ChampionEpicVest.Bonus4Type = (int) eResist.Energy;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(ChampionEpicVest);
}
}
//Moonglow Legs
ChampionEpicLegs = GameServer.Database.FindObjectByKey<ItemTemplate>("ChampionEpicLegs");
if (ChampionEpicLegs == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Champions Epic Legs , creating it ...");
ChampionEpicLegs = new ItemTemplate();
ChampionEpicLegs.Id_nb = "ChampionEpicLegs";
ChampionEpicLegs.Name = "Moonglow Legs";
ChampionEpicLegs.Level = 50;
ChampionEpicLegs.Item_Type = 27;
ChampionEpicLegs.Model = 811;
ChampionEpicLegs.IsDropable = true;
ChampionEpicLegs.IsPickable = true;
ChampionEpicLegs.DPS_AF = 100;
ChampionEpicLegs.SPD_ABS = 27;
ChampionEpicLegs.Object_Type = 38;
ChampionEpicLegs.Quality = 100;
ChampionEpicLegs.Weight = 22;
ChampionEpicLegs.Bonus = 35;
ChampionEpicLegs.MaxCondition = 50000;
ChampionEpicLegs.MaxDurability = 50000;
ChampionEpicLegs.Condition = 50000;
ChampionEpicLegs.Durability = 50000;
ChampionEpicLegs.Bonus1 = 15;
ChampionEpicLegs.Bonus1Type = (int) eStat.CON;
ChampionEpicLegs.Bonus2 = 15;
ChampionEpicLegs.Bonus2Type = (int) eStat.DEX;
ChampionEpicLegs.Bonus3 = 10;
ChampionEpicLegs.Bonus3Type = (int) eResist.Crush;
ChampionEpicLegs.Bonus4 = 18;
ChampionEpicLegs.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(ChampionEpicLegs);
}
}
//Moonglow Sleeves
ChampionEpicArms = GameServer.Database.FindObjectByKey<ItemTemplate>("ChampionEpicArms");
if (ChampionEpicArms == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Champion Epic Arms , creating it ...");
ChampionEpicArms = new ItemTemplate();
ChampionEpicArms.Id_nb = "ChampionEpicArms";
ChampionEpicArms.Name = "Moonglow Sleeves";
ChampionEpicArms.Level = 50;
ChampionEpicArms.Item_Type = 28;
ChampionEpicArms.Model = 812;
ChampionEpicArms.IsDropable = true;
ChampionEpicArms.IsPickable = true;
ChampionEpicArms.DPS_AF = 100;
ChampionEpicArms.SPD_ABS = 27;
ChampionEpicArms.Object_Type = 38;
ChampionEpicArms.Quality = 100;
ChampionEpicArms.Weight = 22;
ChampionEpicArms.Bonus = 35;
ChampionEpicArms.MaxCondition = 50000;
ChampionEpicArms.MaxDurability = 50000;
ChampionEpicArms.Condition = 50000;
ChampionEpicArms.Durability = 50000;
ChampionEpicArms.Bonus1 = 3;
ChampionEpicArms.Bonus1Type = (int) eProperty.Skill_Large_Weapon;
ChampionEpicArms.Bonus2 = 10;
ChampionEpicArms.Bonus2Type = (int) eStat.STR;
ChampionEpicArms.Bonus3 = 10;
ChampionEpicArms.Bonus3Type = (int) eStat.QUI;
ChampionEpicArms.Bonus4 = 33;
ChampionEpicArms.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(ChampionEpicArms);
}
}
NightshadeEpicBoots = GameServer.Database.FindObjectByKey<ItemTemplate>("NightshadeEpicBoots");
if (NightshadeEpicBoots == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Nightshade Epic Boots , creating it ...");
NightshadeEpicBoots = new ItemTemplate();
NightshadeEpicBoots.Id_nb = "NightshadeEpicBoots";
NightshadeEpicBoots.Name = "Moonlit Boots";
NightshadeEpicBoots.Level = 50;
NightshadeEpicBoots.Item_Type = 23;
NightshadeEpicBoots.Model = 750;
NightshadeEpicBoots.IsDropable = true;
NightshadeEpicBoots.IsPickable = true;
NightshadeEpicBoots.DPS_AF = 100;
NightshadeEpicBoots.SPD_ABS = 10;
NightshadeEpicBoots.Object_Type = 33;
NightshadeEpicBoots.Quality = 100;
NightshadeEpicBoots.Weight = 22;
NightshadeEpicBoots.Bonus = 35;
NightshadeEpicBoots.MaxCondition = 50000;
NightshadeEpicBoots.MaxDurability = 50000;
NightshadeEpicBoots.Condition = 50000;
NightshadeEpicBoots.Durability = 50000;
NightshadeEpicBoots.Bonus1 = 12;
NightshadeEpicBoots.Bonus1Type = (int) eStat.STR;
NightshadeEpicBoots.Bonus2 = 15;
NightshadeEpicBoots.Bonus2Type = (int) eStat.DEX;
NightshadeEpicBoots.Bonus3 = 10;
NightshadeEpicBoots.Bonus3Type = (int) eResist.Thrust;
NightshadeEpicBoots.Bonus4 = 24;
NightshadeEpicBoots.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(NightshadeEpicBoots);
}
}
//end item
//Moonlit Coif
NightshadeEpicHelm = GameServer.Database.FindObjectByKey<ItemTemplate>("NightshadeEpicHelm");
if (NightshadeEpicHelm == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Nightshade Epic Helm , creating it ...");
NightshadeEpicHelm = new ItemTemplate();
NightshadeEpicHelm.Id_nb = "NightshadeEpicHelm";
NightshadeEpicHelm.Name = "Moonlit Helm";
NightshadeEpicHelm.Level = 50;
NightshadeEpicHelm.Item_Type = 21;
NightshadeEpicHelm.Model = 1292; //NEED TO WORK ON..
NightshadeEpicHelm.IsDropable = true;
NightshadeEpicHelm.IsPickable = true;
NightshadeEpicHelm.DPS_AF = 100;
NightshadeEpicHelm.SPD_ABS = 10;
NightshadeEpicHelm.Object_Type = 33;
NightshadeEpicHelm.Quality = 100;
NightshadeEpicHelm.Weight = 22;
NightshadeEpicHelm.Bonus = 35;
NightshadeEpicHelm.MaxCondition = 50000;
NightshadeEpicHelm.MaxDurability = 50000;
NightshadeEpicHelm.Condition = 50000;
NightshadeEpicHelm.Durability = 50000;
NightshadeEpicHelm.Bonus1 = 9;
NightshadeEpicHelm.Bonus1Type = (int) eStat.STR;
NightshadeEpicHelm.Bonus2 = 9;
NightshadeEpicHelm.Bonus2Type = (int) eStat.DEX;
NightshadeEpicHelm.Bonus3 = 9;
NightshadeEpicHelm.Bonus3Type = (int) eStat.QUI;
NightshadeEpicHelm.Bonus4 = 39;
NightshadeEpicHelm.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(NightshadeEpicHelm);
}
}
//end item
//Moonlit Gloves
NightshadeEpicGloves = GameServer.Database.FindObjectByKey<ItemTemplate>("NightshadeEpicGloves");
if (NightshadeEpicGloves == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Nightshade Epic Gloves , creating it ...");
NightshadeEpicGloves = new ItemTemplate();
NightshadeEpicGloves.Id_nb = "NightshadeEpicGloves";
NightshadeEpicGloves.Name = "Moonlit Gloves ";
NightshadeEpicGloves.Level = 50;
NightshadeEpicGloves.Item_Type = 22;
NightshadeEpicGloves.Model = 749;
NightshadeEpicGloves.IsDropable = true;
NightshadeEpicGloves.IsPickable = true;
NightshadeEpicGloves.DPS_AF = 100;
NightshadeEpicGloves.SPD_ABS = 10;
NightshadeEpicGloves.Object_Type = 33;
NightshadeEpicGloves.Quality = 100;
NightshadeEpicGloves.Weight = 22;
NightshadeEpicGloves.Bonus = 35;
NightshadeEpicGloves.MaxCondition = 50000;
NightshadeEpicGloves.MaxDurability = 50000;
NightshadeEpicGloves.Condition = 50000;
NightshadeEpicGloves.Durability = 50000;
NightshadeEpicGloves.Bonus1 = 2;
NightshadeEpicGloves.Bonus1Type = (int) eProperty.Skill_Critical_Strike;
NightshadeEpicGloves.Bonus2 = 12;
NightshadeEpicGloves.Bonus2Type = (int) eStat.DEX;
NightshadeEpicGloves.Bonus3 = 13;
NightshadeEpicGloves.Bonus3Type = (int) eStat.QUI;
NightshadeEpicGloves.Bonus4 = 5;
NightshadeEpicGloves.Bonus4Type = (int) eProperty.Skill_Envenom;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(NightshadeEpicGloves);
}
}
//Moonlit Hauberk
NightshadeEpicVest = GameServer.Database.FindObjectByKey<ItemTemplate>("NightshadeEpicVest");
if (NightshadeEpicVest == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Nightshade Epic Vest , creating it ...");
NightshadeEpicVest = new ItemTemplate();
NightshadeEpicVest.Id_nb = "NightshadeEpicVest";
NightshadeEpicVest.Name = "Moonlit Leather Jerking";
NightshadeEpicVest.Level = 50;
NightshadeEpicVest.Item_Type = 25;
NightshadeEpicVest.Model = 746;
NightshadeEpicVest.IsDropable = true;
NightshadeEpicVest.IsPickable = true;
NightshadeEpicVest.DPS_AF = 100;
NightshadeEpicVest.SPD_ABS = 10;
NightshadeEpicVest.Object_Type = 33;
NightshadeEpicVest.Quality = 100;
NightshadeEpicVest.Weight = 22;
NightshadeEpicVest.Bonus = 35;
NightshadeEpicVest.MaxCondition = 50000;
NightshadeEpicVest.MaxDurability = 50000;
NightshadeEpicVest.Condition = 50000;
NightshadeEpicVest.Durability = 50000;
NightshadeEpicVest.Bonus1 = 10;
NightshadeEpicVest.Bonus1Type = (int) eStat.STR;
NightshadeEpicVest.Bonus2 = 10;
NightshadeEpicVest.Bonus2Type = (int) eStat.DEX;
NightshadeEpicVest.Bonus3 = 30;
NightshadeEpicVest.Bonus3Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(NightshadeEpicVest);
}
}
//Moonlit Legs
NightshadeEpicLegs = GameServer.Database.FindObjectByKey<ItemTemplate>("NightshadeEpicLegs");
if (NightshadeEpicLegs == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Nightshade Epic Legs , creating it ...");
NightshadeEpicLegs = new ItemTemplate();
NightshadeEpicLegs.Id_nb = "NightshadeEpicLegs";
NightshadeEpicLegs.Name = "Moonlit Leggings";
NightshadeEpicLegs.Level = 50;
NightshadeEpicLegs.Item_Type = 27;
NightshadeEpicLegs.Model = 747;
NightshadeEpicLegs.IsDropable = true;
NightshadeEpicLegs.IsPickable = true;
NightshadeEpicLegs.DPS_AF = 100;
NightshadeEpicLegs.SPD_ABS = 10;
NightshadeEpicLegs.Object_Type = 33;
NightshadeEpicLegs.Quality = 100;
NightshadeEpicLegs.Weight = 22;
NightshadeEpicLegs.Bonus = 35;
NightshadeEpicLegs.MaxCondition = 50000;
NightshadeEpicLegs.MaxDurability = 50000;
NightshadeEpicLegs.Condition = 50000;
NightshadeEpicLegs.Durability = 50000;
NightshadeEpicLegs.Bonus1 = 16;
NightshadeEpicLegs.Bonus1Type = (int) eStat.CON;
NightshadeEpicLegs.Bonus2 = 15;
NightshadeEpicLegs.Bonus2Type = (int) eStat.DEX;
NightshadeEpicLegs.Bonus3 = 10;
NightshadeEpicLegs.Bonus3Type = (int) eResist.Crush;
NightshadeEpicLegs.Bonus4 = 10;
NightshadeEpicLegs.Bonus4Type = (int) eResist.Slash;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(NightshadeEpicLegs);
}
}
//Moonlit Sleeves
NightshadeEpicArms = GameServer.Database.FindObjectByKey<ItemTemplate>("NightshadeEpicArms");
if (NightshadeEpicArms == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Nightshade Epic Arms , creating it ...");
NightshadeEpicArms = new ItemTemplate();
NightshadeEpicArms.Id_nb = "NightshadeEpicArms";
NightshadeEpicArms.Name = "Moonlit Sleeves";
NightshadeEpicArms.Level = 50;
NightshadeEpicArms.Item_Type = 28;
NightshadeEpicArms.Model = 748;
NightshadeEpicArms.IsDropable = true;
NightshadeEpicArms.IsPickable = true;
NightshadeEpicArms.DPS_AF = 100;
NightshadeEpicArms.SPD_ABS = 10;
NightshadeEpicArms.Object_Type = 33;
NightshadeEpicArms.Quality = 100;
NightshadeEpicArms.Weight = 22;
NightshadeEpicArms.Bonus = 35;
NightshadeEpicArms.MaxCondition = 50000;
NightshadeEpicArms.MaxDurability = 50000;
NightshadeEpicArms.Condition = 50000;
NightshadeEpicArms.Durability = 50000;
NightshadeEpicArms.Bonus1 = 4;
NightshadeEpicArms.Bonus1Type = (int) eProperty.Skill_Celtic_Dual;
NightshadeEpicArms.Bonus2 = 16;
NightshadeEpicArms.Bonus2Type = (int) eStat.CON;
NightshadeEpicArms.Bonus3 = 15;
NightshadeEpicArms.Bonus3Type = (int) eStat.DEX;
NightshadeEpicArms.Bonus4 = 6;
NightshadeEpicArms.Bonus4Type = (int) eResist.Cold;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(NightshadeEpicArms);
}
}
EnchanterEpicBoots = GameServer.Database.FindObjectByKey<ItemTemplate>("EnchanterEpicBoots");
if (EnchanterEpicBoots == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Enchanter Epic Boots , creating it ...");
EnchanterEpicBoots = new ItemTemplate();
EnchanterEpicBoots.Id_nb = "EnchanterEpicBoots";
EnchanterEpicBoots.Name = "Moonspun Boots";
EnchanterEpicBoots.Level = 50;
EnchanterEpicBoots.Item_Type = 23;
EnchanterEpicBoots.Model = 382;
EnchanterEpicBoots.IsDropable = true;
EnchanterEpicBoots.IsPickable = true;
EnchanterEpicBoots.DPS_AF = 50;
EnchanterEpicBoots.SPD_ABS = 0;
EnchanterEpicBoots.Object_Type = 32;
EnchanterEpicBoots.Quality = 100;
EnchanterEpicBoots.Weight = 22;
EnchanterEpicBoots.Bonus = 35;
EnchanterEpicBoots.MaxCondition = 50000;
EnchanterEpicBoots.MaxDurability = 50000;
EnchanterEpicBoots.Condition = 50000;
EnchanterEpicBoots.Durability = 50000;
EnchanterEpicBoots.Bonus1 = 12;
EnchanterEpicBoots.Bonus1Type = (int) eStat.CON;
EnchanterEpicBoots.Bonus2 = 12;
EnchanterEpicBoots.Bonus2Type = (int) eStat.DEX;
EnchanterEpicBoots.Bonus3 = 12;
EnchanterEpicBoots.Bonus3Type = (int) eResist.Body;
EnchanterEpicBoots.Bonus4 = 39;
EnchanterEpicBoots.Bonus4Type = (int) eProperty.MaxHealth;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(EnchanterEpicBoots);
}
}
//end item
//Moonspun Coif
EnchanterEpicHelm = GameServer.Database.FindObjectByKey<ItemTemplate>("EnchanterEpicHelm");
if (EnchanterEpicHelm == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Enchanter Epic Helm , creating it ...");
EnchanterEpicHelm = new ItemTemplate();
EnchanterEpicHelm.Id_nb = "EnchanterEpicHelm";
EnchanterEpicHelm.Name = "Moonspun Cap";
EnchanterEpicHelm.Level = 50;
EnchanterEpicHelm.Item_Type = 21;
EnchanterEpicHelm.Model = 1298; //NEED TO WORK ON..
EnchanterEpicHelm.IsDropable = true;
EnchanterEpicHelm.IsPickable = true;
EnchanterEpicHelm.DPS_AF = 50;
EnchanterEpicHelm.SPD_ABS = 0;
EnchanterEpicHelm.Object_Type = 32;
EnchanterEpicHelm.Quality = 100;
EnchanterEpicHelm.Weight = 22;
EnchanterEpicHelm.Bonus = 35;
EnchanterEpicHelm.MaxCondition = 50000;
EnchanterEpicHelm.MaxDurability = 50000;
EnchanterEpicHelm.Condition = 50000;
EnchanterEpicHelm.Durability = 50000;
EnchanterEpicHelm.Bonus1 = 21;
EnchanterEpicHelm.Bonus1Type = (int) eProperty.MaxHealth;
EnchanterEpicHelm.Bonus2 = 8;
EnchanterEpicHelm.Bonus2Type = (int) eResist.Energy;
EnchanterEpicHelm.Bonus3 = 4;
EnchanterEpicHelm.Bonus3Type = (int) eProperty.Skill_Enchantments;
EnchanterEpicHelm.Bonus4 = 18;
EnchanterEpicHelm.Bonus4Type = (int) eStat.INT;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(EnchanterEpicHelm);
}
}
//end item
//Moonspun Gloves
EnchanterEpicGloves = GameServer.Database.FindObjectByKey<ItemTemplate>("EnchanterEpicGloves");
if (EnchanterEpicGloves == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Enchanter Epic Gloves , creating it ...");
EnchanterEpicGloves = new ItemTemplate();
EnchanterEpicGloves.Id_nb = "EnchanterEpicGloves";
EnchanterEpicGloves.Name = "Moonspun Gloves ";
EnchanterEpicGloves.Level = 50;
EnchanterEpicGloves.Item_Type = 22;
EnchanterEpicGloves.Model = 381;
EnchanterEpicGloves.IsDropable = true;
EnchanterEpicGloves.IsPickable = true;
EnchanterEpicGloves.DPS_AF = 50;
EnchanterEpicGloves.SPD_ABS = 0;
EnchanterEpicGloves.Object_Type = 32;
EnchanterEpicGloves.Quality = 100;
EnchanterEpicGloves.Weight = 22;
EnchanterEpicGloves.Bonus = 35;
EnchanterEpicGloves.MaxCondition = 50000;
EnchanterEpicGloves.MaxDurability = 50000;
EnchanterEpicGloves.Condition = 50000;
EnchanterEpicGloves.Durability = 50000;
EnchanterEpicGloves.Bonus1 = 30;
EnchanterEpicGloves.Bonus1Type = (int) eProperty.MaxHealth;
EnchanterEpicGloves.Bonus2 = 4;
EnchanterEpicGloves.Bonus2Type = (int) eProperty.Skill_Mana;
EnchanterEpicGloves.Bonus3 = 6;
EnchanterEpicGloves.Bonus3Type = (int) eStat.INT;
EnchanterEpicGloves.Bonus4 = 13;
EnchanterEpicGloves.Bonus4Type = (int) eStat.DEX;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(EnchanterEpicGloves);
}
}
//Moonspun Hauberk
EnchanterEpicVest = GameServer.Database.FindObjectByKey<ItemTemplate>("EnchanterEpicVest");
if (EnchanterEpicVest == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Enchanter Epic Vest , creating it ...");
EnchanterEpicVest = new ItemTemplate();
EnchanterEpicVest.Id_nb = "EnchanterEpicVest";
EnchanterEpicVest.Name = "Moonspun Vest";
EnchanterEpicVest.Level = 50;
EnchanterEpicVest.Item_Type = 25;
EnchanterEpicVest.Model = 781;
EnchanterEpicVest.IsDropable = true;
EnchanterEpicVest.IsPickable = true;
EnchanterEpicVest.DPS_AF = 50;
EnchanterEpicVest.SPD_ABS = 0;
EnchanterEpicVest.Object_Type = 32;
EnchanterEpicVest.Quality = 100;
EnchanterEpicVest.Weight = 22;
EnchanterEpicVest.Bonus = 35;
EnchanterEpicVest.MaxCondition = 50000;
EnchanterEpicVest.MaxDurability = 50000;
EnchanterEpicVest.Condition = 50000;
EnchanterEpicVest.Durability = 50000;
EnchanterEpicVest.Bonus1 = 30;
EnchanterEpicVest.Bonus1Type = (int) eProperty.MaxHealth;
EnchanterEpicVest.Bonus2 = 15;
EnchanterEpicVest.Bonus2Type = (int) eStat.INT;
EnchanterEpicVest.Bonus3 = 15;
EnchanterEpicVest.Bonus3Type = (int) eStat.DEX;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(EnchanterEpicVest);
}
}
//Moonspun Legs
EnchanterEpicLegs = GameServer.Database.FindObjectByKey<ItemTemplate>("EnchanterEpicLegs");
if (EnchanterEpicLegs == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Enchanter Epic Legs , creating it ...");
EnchanterEpicLegs = new ItemTemplate();
EnchanterEpicLegs.Id_nb = "EnchanterEpicLegs";
EnchanterEpicLegs.Name = "Moonspun Pants";
EnchanterEpicLegs.Level = 50;
EnchanterEpicLegs.Item_Type = 27;
EnchanterEpicLegs.Model = 379;
EnchanterEpicLegs.IsDropable = true;
EnchanterEpicLegs.IsPickable = true;
EnchanterEpicLegs.DPS_AF = 50;
EnchanterEpicLegs.SPD_ABS = 0;
EnchanterEpicLegs.Object_Type = 32;
EnchanterEpicLegs.Quality = 100;
EnchanterEpicLegs.Weight = 22;
EnchanterEpicLegs.Bonus = 35;
EnchanterEpicLegs.MaxCondition = 50000;
EnchanterEpicLegs.MaxDurability = 50000;
EnchanterEpicLegs.Condition = 50000;
EnchanterEpicLegs.Durability = 50000;
EnchanterEpicLegs.Bonus1 = 16;
EnchanterEpicLegs.Bonus1Type = (int) eStat.CON;
EnchanterEpicLegs.Bonus2 = 15;
EnchanterEpicLegs.Bonus2Type = (int) eStat.DEX;
EnchanterEpicLegs.Bonus3 = 10;
EnchanterEpicLegs.Bonus3Type = (int) eResist.Heat;
EnchanterEpicLegs.Bonus4 = 10;
EnchanterEpicLegs.Bonus4Type = (int) eResist.Cold;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(EnchanterEpicLegs);
}
}
//Moonspun Sleeves
EnchanterEpicArms = GameServer.Database.FindObjectByKey<ItemTemplate>("EnchanterEpicArms");
if (EnchanterEpicArms == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find Enchanter Epic Arms , creating it ...");
EnchanterEpicArms = new ItemTemplate();
EnchanterEpicArms.Id_nb = "EnchanterEpicArms";
EnchanterEpicArms.Name = "Moonspun Sleeves";
EnchanterEpicArms.Level = 50;
EnchanterEpicArms.Item_Type = 28;
EnchanterEpicArms.Model = 380;
EnchanterEpicArms.IsDropable = true;
EnchanterEpicArms.IsPickable = true;
EnchanterEpicArms.DPS_AF = 50;
EnchanterEpicArms.SPD_ABS = 0;
EnchanterEpicArms.Object_Type = 32;
EnchanterEpicArms.Quality = 100;
EnchanterEpicArms.Weight = 22;
EnchanterEpicArms.Bonus = 35;
EnchanterEpicArms.MaxCondition = 50000;
EnchanterEpicArms.MaxDurability = 50000;
EnchanterEpicArms.Condition = 50000;
EnchanterEpicArms.Durability = 50000;
EnchanterEpicArms.Bonus1 = 27;
EnchanterEpicArms.Bonus1Type = (int) eProperty.MaxHealth;
EnchanterEpicArms.Bonus2 = 10;
EnchanterEpicArms.Bonus2Type = (int) eStat.INT;
EnchanterEpicArms.Bonus3 = 5;
EnchanterEpicArms.Bonus3Type = (int) eProperty.Skill_Light;
EnchanterEpicArms.Bonus4 = 10;
EnchanterEpicArms.Bonus4Type = (int) eStat.DEX;
if (SAVE_INTO_DATABASE)
{
GameServer.Database.AddObject(EnchanterEpicArms);
}
}
//Champion Epic Sleeves End
//Item Descriptions End
#endregion
GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));
GameEventMgr.AddHandler(Brigit, GameObjectEvent.Interact, new DOLEventHandler(TalkToBrigit));
GameEventMgr.AddHandler(Brigit, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToBrigit));
/* Now we bring to Brigit the possibility to give this quest to players */
Brigit.AddQuestToGive(typeof (Essence_50));
if (log.IsInfoEnabled)
log.Info("Quest \"" + questTitle + "\" initialized");
}
[ScriptUnloadedEvent]
public static void ScriptUnloaded(DOLEvent e, object sender, EventArgs args)
{
//if not loaded, don't worry
if (Brigit == null)
return;
// remove handlers
GameEventMgr.RemoveHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
GameEventMgr.RemoveHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));
GameEventMgr.RemoveHandler(Brigit, GameObjectEvent.Interact, new DOLEventHandler(TalkToBrigit));
GameEventMgr.RemoveHandler(Brigit, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToBrigit));
/* Now we remove to Brigit the possibility to give this quest to players */
Brigit.RemoveQuestToGive(typeof (Essence_50));
}
protected static void TalkToBrigit(DOLEvent e, object sender, EventArgs args)
{
//We get the player from the event arguments and check if he qualifies
GamePlayer player = ((SourceEventArgs) args).Source as GamePlayer;
if (player == null)
return;
if(Brigit.CanGiveQuest(typeof (Essence_50), player) <= 0)
return;
//We also check if the player is already doing the quest
Essence_50 quest = player.IsDoingQuest(typeof (Essence_50)) as Essence_50;
if (e == GameObjectEvent.Interact)
{
if (quest != null)
{
Brigit.SayTo(player, "Check your Journal for instructions!");
}
else
{
Brigit.SayTo(player, "Hibernia needs your [services]");
}
}
// The player whispered to the NPC
else if (e == GameLivingEvent.WhisperReceive)
{
WhisperReceiveEventArgs wArgs = (WhisperReceiveEventArgs) args;
//Check player is already doing quest
if (quest == null)
{
switch (wArgs.Text)
{
case "services":
player.Out.SendQuestSubscribeCommand(Brigit, QuestMgr.GetIDForQuestType(typeof(Essence_50)), "Will you help Brigit [Path of Essence Level 50 Epic]?");
break;
}
}
else
{
switch (wArgs.Text)
{
case "abort":
player.Out.SendCustomDialog("Do you really want to abort this quest, \nall items gained during quest will be lost?", new CustomDialogResponse(CheckPlayerAbortQuest));
break;
}
}
}
}
public override bool CheckQuestQualification(GamePlayer player)
{
// if the player is already doing the quest his level is no longer of relevance
if (player.IsDoingQuest(typeof (Essence_50)) != null)
return true;
if (player.CharacterClass.ID != (byte) eCharacterClass.Champion &&
player.CharacterClass.ID != (byte) eCharacterClass.Bard &&
player.CharacterClass.ID != (byte) eCharacterClass.Nightshade &&
player.CharacterClass.ID != (byte) eCharacterClass.Enchanter)
return false;
// This checks below are only performed is player isn't doing quest already
//if (player.HasFinishedQuest(typeof(Academy_47)) == 0) return false;
//if (!CheckPartAccessible(player,typeof(CityOfCamelot)))
// return false;
if (player.Level < minimumLevel || player.Level > maximumLevel)
return false;
return true;
}
/* This is our callback hook that will be called when the player clicks
* on any button in the quest offer dialog. We check if he accepts or
* declines here...
*/
private static void CheckPlayerAbortQuest(GamePlayer player, byte response)
{
Essence_50 quest = player.IsDoingQuest(typeof (Essence_50)) as Essence_50;
if (quest == null)
return;
if (response == 0x00)
{
SendSystemMessage(player, "Good, no go out there and finish your work!");
}
else
{
SendSystemMessage(player, "Aborting Quest " + questTitle + ". You can start over again if you want.");
quest.AbortQuest();
}
}
protected static void SubscribeQuest(DOLEvent e, object sender, EventArgs args)
{
QuestEventArgs qargs = args as QuestEventArgs;
if (qargs == null)
return;
if (qargs.QuestID != QuestMgr.GetIDForQuestType(typeof(Essence_50)))
return;
if (e == GamePlayerEvent.AcceptQuest)
CheckPlayerAcceptQuest(qargs.Player, 0x01);
else if (e == GamePlayerEvent.DeclineQuest)
CheckPlayerAcceptQuest(qargs.Player, 0x00);
}
private static void CheckPlayerAcceptQuest(GamePlayer player, byte response)
{
if(Brigit.CanGiveQuest(typeof (Essence_50), player) <= 0)
return;
if (player.IsDoingQuest(typeof (Essence_50)) != null)
return;
if (response == 0x00)
{
player.Out.SendMessage("Our God forgives your laziness, just look out for stray lightning bolts.", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
}
else
{
//Check if we can add the quest!
if (!Brigit.GiveQuest(typeof (Essence_50), player, 1))
return;
player.Out.SendMessage("Kill Caithor in Cursed Forest loc 28k 48k ", eChatType.CT_System, eChatLoc.CL_PopupWindow);
}
}
//Set quest name
public override string Name
{
get { return "The Moonstone Twin (Level 50 Path of Essence Epic)"; }
}
// Define Steps
public override string Description
{
get
{
switch (Step)
{
case 1:
return "[Step #1] Seek out Caithor in Cursed Forest Loc 20k,48k kill him!";
case 2:
return "[Step #2] Return to Brigit and give the Moonstone!";
}
return base.Description;
}
}
public override void Notify(DOLEvent e, object sender, EventArgs args)
{
GamePlayer player = sender as GamePlayer;
if (player==null || player.IsDoingQuest(typeof (Essence_50)) == null)
return;
if (Step == 1 && e == GameLivingEvent.EnemyKilled)
{
EnemyKilledEventArgs gArgs = (EnemyKilledEventArgs) args;
if (gArgs.Target.Name == Caithor.Name)
{
m_questPlayer.Out.SendMessage("You collect the Moonstone from Caithor", eChatType.CT_System, eChatLoc.CL_SystemWindow);
GiveItem(m_questPlayer, Moonstone);
Step = 2;
return;
}
}
if (Step == 2 && e == GamePlayerEvent.GiveItem)
{
GiveItemEventArgs gArgs = (GiveItemEventArgs) args;
if (gArgs.Target.Name == Brigit.Name && gArgs.Item.Id_nb == Moonstone.Id_nb)
{
Brigit.SayTo(player, "You have earned this Epic Armour!");
FinishQuest();
return;
}
}
}
public override void AbortQuest()
{
base.AbortQuest(); //Defined in Quest, changes the state, stores in DB etc ...
RemoveItem(m_questPlayer, Moonstone, false);
}
public override void FinishQuest()
{
if (m_questPlayer.Inventory.IsSlotsFree(6, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
{
RemoveItem(Brigit, m_questPlayer, Moonstone);
base.FinishQuest(); //Defined in Quest, changes the state, stores in DB etc ...
if (m_questPlayer.CharacterClass.ID == (byte)eCharacterClass.Champion)
{
GiveItem(m_questPlayer, ChampionEpicArms);
GiveItem(m_questPlayer, ChampionEpicBoots);
GiveItem(m_questPlayer, ChampionEpicGloves);
GiveItem(m_questPlayer, ChampionEpicHelm);
GiveItem(m_questPlayer, ChampionEpicLegs);
GiveItem(m_questPlayer, ChampionEpicVest);
}
else if (m_questPlayer.CharacterClass.ID == (byte)eCharacterClass.Bard)
{
GiveItem(m_questPlayer, BardEpicArms);
GiveItem(m_questPlayer, BardEpicBoots);
GiveItem(m_questPlayer, BardEpicGloves);
GiveItem(m_questPlayer, BardEpicHelm);
GiveItem(m_questPlayer, BardEpicLegs);
GiveItem(m_questPlayer, BardEpicVest);
}
else if (m_questPlayer.CharacterClass.ID == (byte)eCharacterClass.Enchanter)
{
GiveItem(m_questPlayer, EnchanterEpicArms);
GiveItem(m_questPlayer, EnchanterEpicBoots);
GiveItem(m_questPlayer, EnchanterEpicGloves);
GiveItem(m_questPlayer, EnchanterEpicHelm);
GiveItem(m_questPlayer, EnchanterEpicLegs);
GiveItem(m_questPlayer, EnchanterEpicVest);
}
else if (m_questPlayer.CharacterClass.ID == (byte)eCharacterClass.Nightshade)
{
GiveItem(m_questPlayer, NightshadeEpicArms);
GiveItem(m_questPlayer, NightshadeEpicBoots);
GiveItem(m_questPlayer, NightshadeEpicGloves);
GiveItem(m_questPlayer, NightshadeEpicHelm);
GiveItem(m_questPlayer, NightshadeEpicLegs);
GiveItem(m_questPlayer, NightshadeEpicVest);
}
m_questPlayer.GainExperience(GameLiving.eXPSource.Quest, 1937768448, true);
//m_questPlayer.AddMoney(Money.GetMoney(0,0,0,2,Util.Random(50)), "You recieve {0} as a reward.");
}
else
{
m_questPlayer.Out.SendMessage("You do not have enough free space in your inventory!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
}
}
#region Allakhazam Epic Source
/*
*#25 talk to Brigit
*#26 seek out Loken in Raumarik Loc 47k, 25k, 4k, and kill him purp and 2 blue adds
*#27 return to Brigit
*#28 give her the ball of flame
*#29 talk with Brigit about Lokens demise
*#30 go to MorlinCaan in Jordheim
*#31 give her the sealed pouch
*#32 you get your epic armor as a reward
*/
/*
*Moonsung Boots
*Moonsung Coif
*Moonsung Gloves
*Moonsung Hauberk
*Moonsung Legs
*Moonsung Sleeves
*Shadow Shrouded Boots
*Shadow Shrouded Coif
*Shadow Shrouded Gloves
*Shadow Shrouded Hauberk
*Shadow Shrouded Legs
*Shadow Shrouded Sleeves
*/
#endregion
}
}
|
Dawn-of-Light/DOLSharp
|
GameServerScripts/quests/Hibernia/epic/Essence50.cs
|
C#
|
gpl-2.0
| 52,778 |
/*
* api_trs.c --
*
* Author -- Pedro Aguilar <[email protected]>
*
* Copyright (c) 2007 Pedro Aguilar
*
* Description: Defines the API for the CLI/GUI users
*
*
* 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
*/
/*****************************
* INCLUDES
*****************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include "config.h"
#include "rhal.h"
#include "graph.h"
#include "print.h"
#include "misc.h"
#include "slist.h"
/*****************************
* MACROS
*****************************/
/*****************************
* DATA TYPES
*****************************/
#define trs_error(char *msg, ...) TRS_ERR(msg...)
/*****************************
* FUNCTION IMPLEMENTATION
*****************************/
void trs_error(char *s, ...) {
TRS_ERR(s);
}
|
larytet/taraska
|
rhal/api_trs.c
|
C
|
gpl-2.0
| 1,526 |
/*
* linux/drivers/mmc/card/queue.c
*
* Copyright (C) 2003 Russell King, All Rights Reserved.
* Copyright 2006-2007 Pierre Ossman
*
* 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/slab.h>
#include <linux/module.h>
#include <linux/blkdev.h>
#include <linux/freezer.h>
#include <linux/kthread.h>
#include <linux/scatterlist.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
#include "queue.h"
#define MMC_QUEUE_BOUNCESZ 65536
#define MMC_QUEUE_SUSPENDED (1 << 0)
/*
* Based on benchmark tests the default num of requests to trigger the write
* packing was determined, to keep the read latency as low as possible and
* manage to keep the high write throughput.
*/
#define DEFAULT_NUM_REQS_TO_START_PACK 17
/*
* Prepare a MMC request. This just filters out odd stuff.
*/
static int mmc_prep_request(struct request_queue *q, struct request *req)
{
struct mmc_queue *mq = q->queuedata;
/*
* We only like normal block requests and discards.
*/
if (req->cmd_type != REQ_TYPE_FS && !(req->cmd_flags & REQ_DISCARD)) {
blk_dump_rq_flags(req, "MMC bad request");
return BLKPREP_KILL;
}
if (mq && mmc_card_removed(mq->card))
return BLKPREP_KILL;
req->cmd_flags |= REQ_DONTPREP;
return BLKPREP_OK;
}
static int mmc_queue_thread(void *d)
{
struct mmc_queue *mq = d;
struct request_queue *q = mq->queue;
struct request *req;
current->flags |= PF_MEMALLOC;
down(&mq->thread_sem);
do {
struct mmc_queue_req *tmp;
req = NULL; /* Must be set to NULL at each iteration */
spin_lock_irq(q->queue_lock);
set_current_state(TASK_INTERRUPTIBLE);
req = blk_fetch_request(q);
mq->mqrq_cur->req = req;
spin_unlock_irq(q->queue_lock);
if (req || mq->mqrq_prev->req) {
if (mmc_card_doing_bkops(mq->card))
mmc_interrupt_bkops(mq->card);
set_current_state(TASK_RUNNING);
mq->issue_fn(mq, req);
} else {
if (kthread_should_stop()) {
set_current_state(TASK_RUNNING);
break;
}
mmc_start_bkops(mq->card);
up(&mq->thread_sem);
schedule();
down(&mq->thread_sem);
}
/* Current request becomes previous request and vice versa. */
mq->mqrq_prev->brq.mrq.data = NULL;
mq->mqrq_prev->req = NULL;
tmp = mq->mqrq_prev;
mq->mqrq_prev = mq->mqrq_cur;
mq->mqrq_cur = tmp;
} while (1);
up(&mq->thread_sem);
return 0;
}
/*
* Generic MMC request handler. This is called for any queue on a
* particular host. When the host is not busy, we look for a request
* on any queue on this host, and attempt to issue it. This may
* not be the queue we were asked to process.
*/
static void mmc_request(struct request_queue *q)
{
struct mmc_queue *mq = q->queuedata;
struct request *req;
if (!mq) {
while ((req = blk_fetch_request(q)) != NULL) {
req->cmd_flags |= REQ_QUIET;
__blk_end_request_all(req, -EIO);
}
return;
}
if (!mq->mqrq_cur->req && !mq->mqrq_prev->req)
wake_up_process(mq->thread);
}
static struct scatterlist *mmc_alloc_sg(int sg_len, int *err)
{
struct scatterlist *sg;
sg = kmalloc(sizeof(struct scatterlist)*sg_len, GFP_KERNEL);
if (!sg)
*err = -ENOMEM;
else {
*err = 0;
sg_init_table(sg, sg_len);
}
return sg;
}
static void mmc_queue_setup_discard(struct request_queue *q,
struct mmc_card *card)
{
unsigned max_discard;
max_discard = mmc_calc_max_discard(card);
if (!max_discard)
return;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
q->limits.max_discard_sectors = max_discard;
if (card->erased_byte == 0 && !mmc_can_discard(card))
q->limits.discard_zeroes_data = 1;
q->limits.discard_granularity = card->pref_erase << 9;
/* granularity must not be greater than max. discard */
if (card->pref_erase > max_discard)
q->limits.discard_granularity = 0;
if (mmc_can_secure_erase_trim(card))
queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q);
}
static void mmc_queue_setup_sanitize(struct request_queue *q)
{
queue_flag_set_unlocked(QUEUE_FLAG_SANITIZE, q);
}
/**
* mmc_init_queue - initialise a queue structure.
* @mq: mmc queue
* @card: mmc card to attach this queue
* @lock: queue lock
* @subname: partition subname
*
* Initialise a MMC card request queue.
*/
int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
spinlock_t *lock, const char *subname)
{
struct mmc_host *host = card->host;
u64 limit = BLK_BOUNCE_HIGH;
int ret;
struct mmc_queue_req *mqrq_cur = &mq->mqrq[0];
struct mmc_queue_req *mqrq_prev = &mq->mqrq[1];
if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
limit = *mmc_dev(host)->dma_mask;
mq->card = card;
mq->queue = blk_init_queue(mmc_request, lock);
if (!mq->queue)
return -ENOMEM;
memset(&mq->mqrq_cur, 0, sizeof(mq->mqrq_cur));
memset(&mq->mqrq_prev, 0, sizeof(mq->mqrq_prev));
INIT_LIST_HEAD(&mqrq_cur->packed_list);
INIT_LIST_HEAD(&mqrq_prev->packed_list);
mq->mqrq_cur = mqrq_cur;
mq->mqrq_prev = mqrq_prev;
mq->queue->queuedata = mq;
mq->num_wr_reqs_to_start_packing = DEFAULT_NUM_REQS_TO_START_PACK;
blk_queue_prep_rq(mq->queue, mmc_prep_request);
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue);
if (mmc_can_erase(card))
mmc_queue_setup_discard(mq->queue, card);
if ((mmc_can_sanitize(card) && (host->caps2 & MMC_CAP2_SANITIZE)))
mmc_queue_setup_sanitize(mq->queue);
#ifdef CONFIG_MMC_BLOCK_BOUNCE
if (host->max_segs == 1) {
unsigned int bouncesz;
bouncesz = MMC_QUEUE_BOUNCESZ;
if (bouncesz > host->max_req_size)
bouncesz = host->max_req_size;
if (bouncesz > host->max_seg_size)
bouncesz = host->max_seg_size;
if (bouncesz > (host->max_blk_count * 512))
bouncesz = host->max_blk_count * 512;
if (bouncesz > 512) {
mqrq_cur->bounce_buf = kmalloc(bouncesz, GFP_KERNEL);
if (!mqrq_cur->bounce_buf) {
pr_warning("%s: unable to "
"allocate bounce cur buffer\n",
mmc_card_name(card));
}
mqrq_prev->bounce_buf = kmalloc(bouncesz, GFP_KERNEL);
if (!mqrq_prev->bounce_buf) {
pr_warning("%s: unable to "
"allocate bounce prev buffer\n",
mmc_card_name(card));
kfree(mqrq_cur->bounce_buf);
mqrq_cur->bounce_buf = NULL;
}
}
if (mqrq_cur->bounce_buf && mqrq_prev->bounce_buf) {
blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY);
blk_queue_max_hw_sectors(mq->queue, bouncesz / 512);
blk_queue_max_segments(mq->queue, bouncesz / 512);
blk_queue_max_segment_size(mq->queue, bouncesz);
mqrq_cur->sg = mmc_alloc_sg(1, &ret);
if (ret)
goto cleanup_queue;
mqrq_cur->bounce_sg =
mmc_alloc_sg(bouncesz / 512, &ret);
if (ret)
goto cleanup_queue;
mqrq_prev->sg = mmc_alloc_sg(1, &ret);
if (ret)
goto cleanup_queue;
mqrq_prev->bounce_sg =
mmc_alloc_sg(bouncesz / 512, &ret);
if (ret)
goto cleanup_queue;
}
}
#endif
if (!mqrq_cur->bounce_buf && !mqrq_prev->bounce_buf) {
blk_queue_bounce_limit(mq->queue, limit);
blk_queue_max_hw_sectors(mq->queue,
min(host->max_blk_count, host->max_req_size / 512));
blk_queue_max_segments(mq->queue, host->max_segs);
blk_queue_max_segment_size(mq->queue, host->max_seg_size);
mqrq_cur->sg = mmc_alloc_sg(host->max_segs, &ret);
if (ret)
goto cleanup_queue;
mqrq_prev->sg = mmc_alloc_sg(host->max_segs, &ret);
if (ret)
goto cleanup_queue;
}
sema_init(&mq->thread_sem, 1);
mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d%s",
host->index, subname ? subname : "");
if (IS_ERR(mq->thread)) {
ret = PTR_ERR(mq->thread);
goto free_bounce_sg;
}
return 0;
free_bounce_sg:
kfree(mqrq_cur->bounce_sg);
mqrq_cur->bounce_sg = NULL;
kfree(mqrq_prev->bounce_sg);
mqrq_prev->bounce_sg = NULL;
cleanup_queue:
kfree(mqrq_cur->sg);
mqrq_cur->sg = NULL;
kfree(mqrq_cur->bounce_buf);
mqrq_cur->bounce_buf = NULL;
kfree(mqrq_prev->sg);
mqrq_prev->sg = NULL;
kfree(mqrq_prev->bounce_buf);
mqrq_prev->bounce_buf = NULL;
blk_cleanup_queue(mq->queue);
return ret;
}
void mmc_cleanup_queue(struct mmc_queue *mq)
{
struct request_queue *q = mq->queue;
unsigned long flags;
struct mmc_queue_req *mqrq_cur = mq->mqrq_cur;
struct mmc_queue_req *mqrq_prev = mq->mqrq_prev;
/* Make sure the queue isn't suspended, as that will deadlock */
mmc_queue_resume(mq);
/* Then terminate our worker thread */
kthread_stop(mq->thread);
/* Empty the queue */
spin_lock_irqsave(q->queue_lock, flags);
q->queuedata = NULL;
blk_start_queue(q);
spin_unlock_irqrestore(q->queue_lock, flags);
kfree(mqrq_cur->bounce_sg);
mqrq_cur->bounce_sg = NULL;
kfree(mqrq_cur->sg);
mqrq_cur->sg = NULL;
kfree(mqrq_cur->bounce_buf);
mqrq_cur->bounce_buf = NULL;
kfree(mqrq_prev->bounce_sg);
mqrq_prev->bounce_sg = NULL;
kfree(mqrq_prev->sg);
mqrq_prev->sg = NULL;
kfree(mqrq_prev->bounce_buf);
mqrq_prev->bounce_buf = NULL;
mq->card = NULL;
}
EXPORT_SYMBOL(mmc_cleanup_queue);
/**
* mmc_queue_suspend - suspend a MMC request queue
* @mq: MMC queue to suspend
*
* Stop the block request queue, and wait for our thread to
* complete any outstanding requests. This ensures that we
* won't suspend while a request is being processed.
*/
int mmc_queue_suspend(struct mmc_queue *mq)
{
struct request_queue *q = mq->queue;
unsigned long flags;
int rc = 0;
if (!(mq->flags & MMC_QUEUE_SUSPENDED)) {
mq->flags |= MMC_QUEUE_SUSPENDED;
spin_lock_irqsave(q->queue_lock, flags);
blk_stop_queue(q);
spin_unlock_irqrestore(q->queue_lock, flags);
rc = down_trylock(&mq->thread_sem);
if (rc) {
/*
* Failed to take the lock so better to abort the
* suspend because mmcqd thread is processing requests.
*/
mq->flags &= ~MMC_QUEUE_SUSPENDED;
spin_lock_irqsave(q->queue_lock, flags);
blk_start_queue(q);
spin_unlock_irqrestore(q->queue_lock, flags);
rc = -EBUSY;
}
}
return rc;
}
/**
* mmc_queue_resume - resume a previously suspended MMC request queue
* @mq: MMC queue to resume
*/
void mmc_queue_resume(struct mmc_queue *mq)
{
struct request_queue *q = mq->queue;
unsigned long flags;
if (mq->flags & MMC_QUEUE_SUSPENDED) {
mq->flags &= ~MMC_QUEUE_SUSPENDED;
up(&mq->thread_sem);
spin_lock_irqsave(q->queue_lock, flags);
blk_start_queue(q);
spin_unlock_irqrestore(q->queue_lock, flags);
}
}
static unsigned int mmc_queue_packed_map_sg(struct mmc_queue *mq,
struct mmc_queue_req *mqrq,
struct scatterlist *sg)
{
struct scatterlist *__sg;
unsigned int sg_len = 0;
struct request *req;
enum mmc_packed_cmd cmd;
cmd = mqrq->packed_cmd;
if (cmd == MMC_PACKED_WRITE) {
__sg = sg;
sg_set_buf(__sg, mqrq->packed_cmd_hdr,
sizeof(mqrq->packed_cmd_hdr));
sg_len++;
__sg->page_link &= ~0x02;
}
__sg = sg + sg_len;
list_for_each_entry(req, &mqrq->packed_list, queuelist) {
sg_len += blk_rq_map_sg(mq->queue, req, __sg);
__sg = sg + (sg_len - 1);
(__sg++)->page_link &= ~0x02;
}
sg_mark_end(sg + (sg_len - 1));
return sg_len;
}
/*
* Prepare the sg list(s) to be handed of to the host driver
*/
unsigned int mmc_queue_map_sg(struct mmc_queue *mq, struct mmc_queue_req *mqrq)
{
unsigned int sg_len;
size_t buflen;
struct scatterlist *sg;
int i;
if (!mqrq->bounce_buf) {
if (!list_empty(&mqrq->packed_list))
return mmc_queue_packed_map_sg(mq, mqrq, mqrq->sg);
else
return blk_rq_map_sg(mq->queue, mqrq->req, mqrq->sg);
}
BUG_ON(!mqrq->bounce_sg);
if (!list_empty(&mqrq->packed_list))
sg_len = mmc_queue_packed_map_sg(mq, mqrq, mqrq->bounce_sg);
else
sg_len = blk_rq_map_sg(mq->queue, mqrq->req, mqrq->bounce_sg);
mqrq->bounce_sg_len = sg_len;
buflen = 0;
for_each_sg(mqrq->bounce_sg, sg, sg_len, i)
buflen += sg->length;
sg_init_one(mqrq->sg, mqrq->bounce_buf, buflen);
return 1;
}
/*
* If writing, bounce the data to the buffer before the request
* is sent to the host driver
*/
void mmc_queue_bounce_pre(struct mmc_queue_req *mqrq)
{
if (!mqrq->bounce_buf)
return;
if (rq_data_dir(mqrq->req) != WRITE)
return;
sg_copy_to_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len,
mqrq->bounce_buf, mqrq->sg[0].length);
}
/*
* If reading, bounce the data from the buffer after the request
* has been handled by the host driver
*/
void mmc_queue_bounce_post(struct mmc_queue_req *mqrq)
{
if (!mqrq->bounce_buf)
return;
if (rq_data_dir(mqrq->req) != READ)
return;
sg_copy_from_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len,
mqrq->bounce_buf, mqrq->sg[0].length);
}
|
hanjin1987/hw_msm8x25_kernel
|
drivers/mmc/card/queue.c
|
C
|
gpl-2.0
| 12,465 |
/**
* OWASP Benchmark Project v1.1
*
* This file is part of the Open Web Application Security Project (OWASP)
* Benchmark Project. For details, please see
* <a href="https://www.owasp.org/index.php/Benchmark">https://www.owasp.org/index.php/Benchmark</a>.
*
* The Benchmark 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.
*
* The Benchmark 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
*
* @author Dave Wichers <a href="https://www.aspectsecurity.com">Aspect Security</a>
* @created 2015
*/
package org.owasp.benchmark.testcode;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/BenchmarkTest09680")
public class BenchmarkTest09680 extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String param = "";
java.util.Enumeration<String> headers = request.getHeaders("foo");
if (headers.hasMoreElements()) {
param = headers.nextElement(); // just grab first element
}
String bar = new Test().doSomething(param);
String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='"+ bar +"'";
try {
java.sql.Statement statement = org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
statement.execute( sql, new int[] { 1, 2 } );
} catch (java.sql.SQLException e) {
throw new ServletException(e);
}
} // end doPost
private class Test {
public String doSomething(String param) throws ServletException, IOException {
String bar;
// Simple ? condition that assigns constant to bar on true condition
int i = 106;
bar = (7*18) + i > 200 ? "This_should_always_happen" : param;
return bar;
}
} // end innerclass Test
} // end DataflowThruInnerClass
|
iammyr/Benchmark
|
src/main/java/org/owasp/benchmark/testcode/BenchmarkTest09680.java
|
Java
|
gpl-2.0
| 2,468 |
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2007 Advanced Micro Devices, Inc.
* Copyright (C) 2007-2009 coresystems GmbH
*
* 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.
*
* 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.
*/
/* SPDs for DDR2 SDRAM */
#define SPD_MEM_TYPE 2
#define SPD_MEM_TYPE_SDRAM_DDR 0x07
#define SPD_MEM_TYPE_SDRAM_DDR2 0x08
#define SPD_DIMM_TYPE 20 /* x bit0 or bit4 =1 mean registered*/
#define SPD_DIMM_TYPE_RDIMM (1<<0)
#define SPD_DIMM_TYPE_UDIMM (1<<1)
#define SPD_DIMM_TYPE_SODIMM (1<<2)
#define SPD_DIMM_TYPE_uDIMM (1<<3)
#define SPD_DIMM_TYPE_mRDIMM (1<<4)
#define SPD_DIMM_TYPE_mUDIMM (1<<5)
#define SPD_MOD_ATTRIB 21
#define SPD_MOD_ATTRIB_DIFCK 0x20
#define SPD_MOD_ATTRIB_REGADC 0x11 /* x */
#define SPD_MOD_ATTRIB_PROBE 0x40
#define SPD_DEV_ATTRIB 22 /* Device attributes --- general */
#define SPD_DIMM_CONF_TYPE 11
#define SPD_DIMM_CONF_TYPE_ECC 0x02
#define SPD_DIMM_CONF_TYPE_ADDR_PARITY 0x04 /* ? */
#define SPD_CAS_LAT_MIN_X_1 23
#define SPD_CAS_LAT_MAX_X_1 24
#define SPD_CAS_LAT_MIN_X_2 25
#define SPD_CAS_LAT_MAX_X_2 26
#define SPD_BURST_LENGTHS 16
#define SPD_BURST_LENGTHS_4 (1<<2)
#define SPD_BURST_LENGTHS_8 (1<<3)
#define SPD_ROW_NUM 3 /* Number of Row addresses */
#define SPD_COL_NUM 4 /* Number of Column addresses */
#define SPD_BANK_NUM 17 /* SDRAM Device attributes - Number of Banks on
SDRAM device, it could be 0x4, 0x8, so address
lines for that would be 2, and 3 */
/* Number of Ranks bit [2:0], Package (bit4, 1=stack, 0=planr), Height bit[7:5] */
#define SPD_MOD_ATTRIB_RANK 5
#define SPD_MOD_ATTRIB_RANK_NUM_SHIFT 0
#define SPD_MOD_ATTRIB_RANK_NUM_MASK 0x07
#define SPD_MOD_ATTRIB_RANK_NUM_BASE 1
#define SPD_MOD_ATTRIB_RANK_NUM_MIN 1
#define SPD_MOD_ATTRIB_RANK_NUM_MAX 8
#define SPD_RANK_SIZE 31 /* Only one bit is set */
#define SPD_RANK_SIZE_1GB (1<<0)
#define SPD_RANK_SIZE_2GB (1<<1)
#define SPD_RANK_SIZE_4GB (1<<2)
#define SPD_RANK_SIZE_8GB (1<<3)
#define SPD_RANK_SIZE_16GB (1<<4)
#define SPD_RANK_SIZE_128MB (1<<5)
#define SPD_RANK_SIZE_256MB (1<<6)
#define SPD_RANK_SIZE_512MB (1<<7)
#define SPD_DATA_WIDTH 6 /* valid value 0, 32, 33, 36, 64, 72, 80, 128, 144, 254, 255 */
#define SPD_PRI_WIDTH 13 /* Primary SDRAM Width, it could be 0x08 or 0x10 */
#define SPD_ERR_WIDTH 14 /* Error Checking SDRAM Width, it could be 0x08 or 0x10 */
#define SPD_CAS_LAT 18 /* SDRAM Device Attributes -- CAS Latency */
#define SPD_CAS_LAT_2 (1<<2)
#define SPD_CAS_LAT_3 (1<<3)
#define SPD_CAS_LAT_4 (1<<4)
#define SPD_CAS_LAT_5 (1<<5)
#define SPD_CAS_LAT_6 (1<<6)
#define SPD_TRP 27 /* bit [7:2] = 1-63 ns, bit [1:0] 0.25ns+, final value ((val>>2) + (val & 3) * 0.25)ns */
#define SPD_TRRD 28
#define SPD_TRCD 29
#define SPD_TRAS 30
#define SPD_TWR 36 /* x */
#define SPD_TWTR 37 /* x */
#define SPD_TRTP 38 /* x */
#define SPD_EX_TRC_TRFC 40
#define SPD_TRC 41 /* add byte 0x40 bit [3:1] , so final val41+ table[((val40>>1) & 0x7)] ... table[]={0, 0.25, 0.33, 0.5, 0.75, 0, 0}*/
#define SPD_TRFC 42 /* add byte 0x40 bit [6:4] , so final val42+ table[((val40>>4) & 0x7)] + (val40 & 1)*256*/
#define SPD_TREF 12
|
latelee/coreboot
|
src/include/spd_ddr2.h
|
C
|
gpl-2.0
| 3,520 |
#include "gdalhotstarter.h"
#include <ogrsf_frmts.h>
#include "gdalutilities.h"
#include <dmgdalsystem.h>
#include <sstream>
DM_DECLARE_CUSTOM_NODE_NAME(GDALHotStarter, Load Simulation DB , Data Import and Export)
DM::ViewContainer *GDALHotStarter::viewContainerFactory(OGRLayer *lyr, OGRLayer *def_lyr)
{
OGRFeatureDefn * def = lyr->GetLayerDefn();
int dm_geometry = DM::GDALUtilities::OGRtoDMGeometry(def);
std::map<std::string, std::string> translator;
DM::ViewContainer * view = new DM::ViewContainer(lyr->GetName(), dm_geometry, DM::WRITE);
std::stringstream attribute_filter;
attribute_filter << "view_name = '";
attribute_filter << lyr->GetName();
attribute_filter << "'";
def_lyr->SetAttributeFilter(attribute_filter.str().c_str());
def_lyr->ResetReading();
OGRFeature * f;
while (f = def_lyr->GetNextFeature()) {
DM::Logger(DM::Debug) << f->GetFieldAsString("attribute_name");
std::string attribute_name = QString::fromStdString(f->GetFieldAsString("attribute_name")).toStdString();
if (attribute_name == "DEFINITION")
continue;
std::string data_type = QString::fromStdString(f->GetFieldAsString("data_type")).toStdString();
view->addAttribute(attribute_name.c_str(), DM::GDALUtilities::AttributeTypeStringToType(data_type), DM::WRITE);
OGRFeature::DestroyFeature(f);
//def_lyr->GetNextFeature();
}
return view;
}
GDALHotStarter::GDALHotStarter()
{
GDALModule = true;
OGRRegisterAll();
this->hotStartDatabase = "";
this->addParameter("hot_start_database", DM::FILENAME, &hotStartDatabase);
}
void GDALHotStarter::init()
{
if (this->hotStartDatabase.empty()) {
DM::Logger(DM::Warning) << "No database set";
return;
}
GDALDataset* poDS = (GDALDataset*) GDALOpenEx( this->hotStartDatabase.c_str(), GDAL_OF_VECTOR, NULL, NULL, NULL );
//OGRDataSource *poDS = OGRSFDriverRegistrar::Open(this->hotStartDatabase.c_str());
if (!poDS) {
DM::Logger(DM::Warning) << "Error loading database: " << this->hotStartDatabase;
return;
}
int layer_counter = poDS->GetLayerCount();
std::vector<DM::ViewContainer*> datastream;
OGRLayer * layer_def = poDS->GetLayerByName("dynamind_table_definitions");
if (!layer_def)
return;
for (int i = 0; i < layer_counter; i++) {
OGRLayer * lyr = poDS->GetLayer(i);
if (QString::fromStdString(lyr->GetName()) == "dynamind_table_definitions")
continue;
DM::ViewContainer * v = viewContainerFactory(lyr, layer_def);
if (v) {
datastream.push_back(v);
}
}
this->registerViewContainers(datastream);
GDALClose(poDS);
}
void GDALHotStarter::run()
{
DM::GDALSystem * sys = this->getGDALData("city");
sys->setGDALDatabase(this->hotStartDatabase);
}
string GDALHotStarter::getHelpUrl()
{
return "/DynaMind-GDALModules/gdalhotstarter.html";
}
|
iut-ibk/DynaMind-ToolBox
|
DynaMind-GDALModules/src/standard/gdalhotstarter.cpp
|
C++
|
gpl-2.0
| 2,751 |
/***************************************************************************
* 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. *
* *
* copyright (C) 2012-2014 *
* Umbrello UML Modeller Authors <[email protected]> *
***************************************************************************/
#include "cmd_createDiagram.h"
#include "model_utils.h"
#include "umldoc.h"
#include "umlscene.h"
#include "umlview.h"
#include <klocale.h>
namespace Uml
{
CmdCreateDiagram::CmdCreateDiagram(UMLDoc* doc, Uml::DiagramType::Enum type, const QString& name)
: QUndoCommand(),
m_name(name),
m_type(type),
m_pUMLDoc(doc),
m_pUMLView(0)
{
QString msg = i18n("Create diagram %1: %2", DiagramType::toString(type), name);
setText(msg);
m_sceneId = Uml::ID::None;
}
CmdCreateDiagram::~CmdCreateDiagram()
{
}
void CmdCreateDiagram::redo()
{
if (!m_pUMLDoc->findView(m_type, m_name, true)) {
Uml::ModelType::Enum modelType = Model_Utils::convert_DT_MT(m_type);
UMLFolder* folder = m_pUMLDoc->rootFolder(modelType);
m_pUMLView = m_pUMLDoc->createDiagram(folder, m_type, m_name, m_sceneId);
}
// Remember the scene-ID, it might be auto generated. The ID must
// not change after undo/redo because other commands may try to
// lookup the diagram later.
m_sceneId = m_pUMLView->umlScene()->ID();
}
void CmdCreateDiagram::undo()
{
if (m_pUMLView) {
m_pUMLDoc->removeDiagramCmd(m_sceneId);
}
}
}
|
behlingc/umbrello-behlingc
|
umbrello/cmds/cmd_createDiagram.cpp
|
C++
|
gpl-2.0
| 2,004 |
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* HelloWorlds View
*/
class GeoiViewGeoi extends JView
{
/**
* HelloWorlds view display method
* @return void
*/
function display($tpl = null)
{
// Get data from the model
//$items = $this->get('Items');
//$pagination = $this->get('Pagination');
//$this->msg = $this->get('Msg');
///$this->creartabla();
//$model = $this->getModel();
//$model->creartabla();
//$this->msg = $this->get('Msg');
//$this->msg2 = $this->get('Msg2');
//echo $model->msg2;
//var_dump($abc);
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Assign data to the view
//$this->items = $items;
//$this->pagination = $pagination;
// Display the template
parent::display($tpl);
}
}
|
crablasph/Joomla-GeoI
|
Joomla/administrator/components/com_geoi/views/geoi/view.html.php
|
PHP
|
gpl-2.0
| 1,281 |
(function($) {
"use strict";
var $page = 0;
var $ajax_url = ya_portfolio.ajax_url;
var $ya_style = ya_portfolio.style;
var $categories = ya_portfolio.categories;
var $max_page = ya_portfolio.max_page;
var $attributes = ya_portfolio.attributes;
var $number = ya_portfolio.number;
var $offset = ya_portfolio.offset;
var $orderby = ya_portfolio.orderby;
var $order = ya_portfolio.order;
var $pf_id = ya_portfolio.pf_id;
var $container_id = $('#container-'+ $pf_id);
var $tab_id = $('#tab-'+ $pf_id);
var $container = $container_id; //The ID for the list with all the blog posts
if( $ya_style == 'fitRows' ){
$container.isotope({ //Isotope options, 'item' matches the class in the PHP
layoutMode : $ya_style
});
}else{
$container.isotope({ //Isotope options, 'item' matches the class in the PHP
layoutMode : $ya_style,
masonry: {
columnWidth: '.portfolio-item'
}
});
}
//Add the class selected to the item that is clicked, and remove from the others
var $optionSets = $tab_id,
$optionLinks = $optionSets.find('li');
$optionLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ( $this.hasClass('selected') ) {
return false;
}
var $optionSet = $this.parents($tab_id);
$optionSets.find('.selected').removeClass('selected');
$this.addClass('selected');
//When an item is clicked, sort the items.
var selector = $(this).attr('data-portfolio-filter');
$container.isotope({ filter: selector });
return false;
});
var $page = 1;
var $btn_loadmore = $('#'+ $pf_id + ' .btn-loadmore');
$btn_loadmore.on("click", function(){
if( $page >= $max_page ){
return false;
}
$(this).addClass('btn-loading');
jQuery.ajax({
type: "POST",
url: $ajax_url,
data: ({
action : "sw_portfolio_ajax",
catid : $categories,
numb : $number,
orderby: $orderby,
order : $order,
offset : $offset,
page : $page,
style : $ya_style,
attributes: $attributes
}),
success: function(data) {
var $newItems = $(data);
if( $newItems.length > 0 ){
$newItems.imagesLoaded( function(){
$container_id.isotope("insert",$newItems).isotope();
});
$btn_loadmore.removeClass('btn-loading');
if( $newItems.length < $number ){
$btn_loadmore.addClass( 'btn-loaded' );
}
$page = $page + 1;
}else{
$btn_loadmore.addClass( 'btn-loaded' );
}
}
});
});
})(jQuery);
|
chiricos/cruz
|
wp-content/themes/sw_atom/js/portfolio.js
|
JavaScript
|
gpl-2.0
| 2,543 |
FILE *romfopen(char *fn, char *mode);
int rom_present(char *fn);
typedef struct rom_t
{
uint8_t *rom;
uint32_t mask;
mem_mapping_t mapping;
} rom_t;
int rom_init(rom_t *rom, char *fn, uint32_t address, int size, int mask, int file_offset, uint32_t flags);
int rom_init_interleaved(rom_t *rom, char *fn_low, char *fn_high, uint32_t address, int size, int mask, int file_offset, uint32_t flags);
uint8_t rom_read(uint32_t addr, void *p);
uint16_t rom_readw(uint32_t addr, void *p);
uint32_t rom_readl(uint32_t addr, void *p);
|
mborjesson/PCem-wx-SDL2
|
src/rom.h
|
C
|
gpl-2.0
| 567 |
/**
* jquery-plugin-postit - style definitions
*
* Copyright (c) 2007, 2008 Glencoe Software, Inc. All rights reserved.
*
* This software is distributed under the terms described by the LICENCE file
* you can find at the root of the distribution bundle, which states you are
* free to use it only for non commercial purposes.
* If the file is missing please request a copy by contacting
* [email protected].
*/
.postit {
position: absolute;
display: none;
top: 0px;
background-color: #FF0;
z-index: 10;
border: 1px solid;
overflow: hidden;
_width: 25%;
}
.postit h1 {
margin: 0px;
padding: 0px 2em;
background-color: #EE0;
height: 1.5em;
font-size: 1.0em;
font-weight: bold;
text-align: center;
cursor: -moz-grab;
cursor: pointer, auto;
}
.postit h2 {
font-size: 1.0em;
font-style: italic;
text-align: center;
text-decoration: underline;
margin-bottom: 0px;
}
/*
.postit td strong {
font-family: Courier New, monospace;
font-size: 1.1em;
}
*/
.postit ul {
/*
font-family: Courier New, monospace;
*/
list-style-type: none;
margin-left: 0px;
padding: 0px 0.5em;
}
.postit.collapsed {
height: 1.5em !important;
border-bottom-style: dashed;
min-height: 0px !important;
}
.postit-content {
overflow: auto;
max-height: 600px;
}
.collapsed .postit-content {
overflow: hidden;
}
.postit-close-btn {
position: absolute;
right: 0px;
top: 0px;
background-image: url("../img/close.gif");
background-repeat: no-repeat;
background-position: center center;
width: 1.5em;
height: 1.5em;
cursor: pointer;
}
.postit-resize-bar {
height: 8px;
background-color: #EDEDED;
font-size: 1px;
}
.postit-resize-btn {
position: absolute;
right: 0px;
bottom: 0px;
background-image: url("../img/resize.gif");
background-repeat: no-repeat;
background-position: center center;
height: 8px;
width: 8px;
cursor: se-resize;
}
.postit-toggle-btn {
position: absolute;
left: 0px;
top: 0px;
background: url('../img/white_arrow_up.gif') no-repeat center;
background-position: center center;
width: 1.5em;
height: 1.5em;
cursor: pointer;
}
.postit.collapsed .postit-toggle-btn {
background: url('../img/white_arrow_down.gif') no-repeat center;
}
.postit table {
width: 0px;
}
.postit tr > td:first-child {
text-align: right;
}
.postit .ui-resizable {
position: initial;
}
.postit .ui-icon {
background-image: url(../../3rdparty/jquery-ui-1.8.19/themes/base/images/ui-icons_222222_256x240.png);
}
|
emilroz/openmicroscopy
|
components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/css/ome.postit.css
|
CSS
|
gpl-2.0
| 2,541 |
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code 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 code 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 work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/**
* @test
* @bug 8073184
* @summary CastII that guards counted loops confuses range check elimination with LoopLimitCheck off
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LoopLimitCheck -XX:CompileOnly=TestCastIINoLoopLimitCheck.m -Xcomp TestCastIINoLoopLimitCheck
*
*/
public class TestCastIINoLoopLimitCheck {
static void m(int i, int index, char[] buf) {
while (i >= 65536) {
i = i / 100;
buf [--index] = 0;
buf [--index] = 1;
}
}
static public void main(String[] args) {
m(0, 0, null);
}
}
|
gaoxiaojun/dync
|
test/compiler/loopopts/TestCastIINoLoopLimitCheck.java
|
Java
|
gpl-2.0
| 1,681 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.5.0_22) on Tue May 29 00:11:55 CEST 2012 -->
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>
javax.microedition.io (leJOS NXJ API documentation)
</TITLE>
<META NAME="keywords" CONTENT="javax.microedition.io package">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<FONT size="+1" CLASS="FrameTitleFont">
<A HREF="../../../javax/microedition/io/package-summary.html" target="classFrame">javax.microedition.io</A></FONT>
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">
Interfaces</FONT>
<FONT CLASS="FrameItemFont">
<BR>
<A HREF="Connection.html" title="interface in javax.microedition.io" target="classFrame"><I>Connection</I></A>
<BR>
<A HREF="InputConnection.html" title="interface in javax.microedition.io" target="classFrame"><I>InputConnection</I></A>
<BR>
<A HREF="OutputConnection.html" title="interface in javax.microedition.io" target="classFrame"><I>OutputConnection</I></A>
<BR>
<A HREF="StreamConnection.html" title="interface in javax.microedition.io" target="classFrame"><I>StreamConnection</I></A>
<BR>
<A HREF="StreamConnectionNotifier.html" title="interface in javax.microedition.io" target="classFrame"><I>StreamConnectionNotifier</I></A></FONT></TD>
</TR>
</TABLE>
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">
Classes</FONT>
<FONT CLASS="FrameItemFont">
<BR>
<A HREF="Connector.html" title="class in javax.microedition.io" target="classFrame">Connector</A></FONT></TD>
</TR>
</TABLE>
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">
Exceptions</FONT>
<FONT CLASS="FrameItemFont">
<BR>
<A HREF="ConnectionNotFoundException.html" title="class in javax.microedition.io" target="classFrame">ConnectionNotFoundException</A></FONT></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|
gusDuarte/enchanting-usb3
|
leJOS_NXJ_0.9.1beta-3/docs/nxt/javax/microedition/io/package-frame.html
|
HTML
|
gpl-2.0
| 2,135 |
/*
* linux/drivers/mmc/core/core.c
*
* Copyright (C) 2003-2004 Russell King, All Rights Reserved.
* SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
* Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
* MMCv4 support Copyright (C) 2006 Philip Langdale, 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.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/pagemap.h>
#include <linux/err.h>
#include <linux/leds.h>
#include <linux/scatterlist.h>
#include <linux/log2.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/wakelock.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include "core.h"
#include "bus.h"
#include "host.h"
#include "sdio_bus.h"
#include "mmc_ops.h"
#include "sd_ops.h"
#include "sdio_ops.h"
static struct workqueue_struct *workqueue;
/*
* Enabling software CRCs on the data blocks can be a significant (30%)
* performance cost, and for other reasons may not always be desired.
* So we allow it it to be disabled.
*/
int use_spi_crc = 0;
module_param(use_spi_crc, bool, 0);
/*
* We normally treat cards as removed during suspend if they are not
* known to be on a non-removable bus, to avoid the risk of writing
* back data to a different card after resume. Allow this to be
* overridden if necessary.
*/
#ifdef CONFIG_MMC_UNSAFE_RESUME
int mmc_assume_removable;
#else
int mmc_assume_removable = 1;
#endif
EXPORT_SYMBOL(mmc_assume_removable);
module_param_named(removable, mmc_assume_removable, bool, 0644);
MODULE_PARM_DESC(
removable,
"MMC/SD cards are removable and may be removed during suspend");
/*
* Internal function. Schedule delayed work in the MMC work queue.
*/
static int mmc_schedule_delayed_work(struct delayed_work *work,
unsigned long delay)
{
return queue_delayed_work(workqueue, work, delay);
}
/*
* Internal function. Flush all scheduled work from the MMC work queue.
*/
static void mmc_flush_scheduled_work(void)
{
flush_workqueue(workqueue);
}
/**
* mmc_request_done - finish processing an MMC request
* @host: MMC host which completed request
* @mrq: MMC request which request
*
* MMC drivers should call this function when they have completed
* their processing of a request.
*/
void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
{
struct mmc_command *cmd = mrq->cmd;
int err = cmd->error;
if (err && cmd->retries && mmc_host_is_spi(host)) {
if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND)
cmd->retries = 0;
}
if (err && cmd->retries) {
pr_debug("%s: req failed (CMD%u): %d, retrying...\n",
mmc_hostname(host), cmd->opcode, err);
cmd->retries--;
cmd->error = 0;
host->ops->request(host, mrq);
} else {
led_trigger_event(host->led, LED_OFF);
pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n",
mmc_hostname(host), cmd->opcode, err,
cmd->resp[0], cmd->resp[1],
cmd->resp[2], cmd->resp[3]);
if (mrq->data) {
pr_debug("%s: %d bytes transferred: %d\n",
mmc_hostname(host),
mrq->data->bytes_xfered, mrq->data->error);
}
if (mrq->stop) {
pr_debug("%s: (CMD%u): %d: %08x %08x %08x %08x\n",
mmc_hostname(host), mrq->stop->opcode,
mrq->stop->error,
mrq->stop->resp[0], mrq->stop->resp[1],
mrq->stop->resp[2], mrq->stop->resp[3]);
}
if (mrq->done)
mrq->done(mrq);
mmc_host_clk_release(host);
}
}
EXPORT_SYMBOL(mmc_request_done);
static void
mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
{
#ifdef CONFIG_MMC_DEBUG
unsigned int i, sz;
struct scatterlist *sg;
#endif
pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
mmc_hostname(host), mrq->cmd->opcode,
mrq->cmd->arg, mrq->cmd->flags);
if (mrq->data) {
pr_debug("%s: blksz %d blocks %d flags %08x "
"tsac %d ms nsac %d\n",
mmc_hostname(host), mrq->data->blksz,
mrq->data->blocks, mrq->data->flags,
mrq->data->timeout_ns / 1000000,
mrq->data->timeout_clks);
}
if (mrq->stop) {
pr_debug("%s: CMD%u arg %08x flags %08x\n",
mmc_hostname(host), mrq->stop->opcode,
mrq->stop->arg, mrq->stop->flags);
}
WARN_ON(!host->claimed);
mrq->cmd->error = 0;
mrq->cmd->mrq = mrq;
if (mrq->data) {
BUG_ON(mrq->data->blksz > host->max_blk_size);
BUG_ON(mrq->data->blocks > host->max_blk_count);
BUG_ON(mrq->data->blocks * mrq->data->blksz >
host->max_req_size);
#ifdef CONFIG_MMC_DEBUG
sz = 0;
for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i)
sz += sg->length;
BUG_ON(sz != mrq->data->blocks * mrq->data->blksz);
#endif
mrq->cmd->data = mrq->data;
mrq->data->error = 0;
mrq->data->mrq = mrq;
if (mrq->stop) {
mrq->data->stop = mrq->stop;
mrq->stop->error = 0;
mrq->stop->mrq = mrq;
}
}
mmc_host_clk_hold(host);
led_trigger_event(host->led, LED_FULL);
host->ops->request(host, mrq);
}
static void mmc_wait_done(struct mmc_request *mrq)
{
complete(mrq->done_data);
}
/**
* mmc_wait_for_req - start a request and wait for completion
* @host: MMC host to start command
* @mrq: MMC request to start
*
* Start a new MMC custom command request for a host, and wait
* for the command to complete. Does not attempt to parse the
* response.
*/
void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
{
DECLARE_COMPLETION_ONSTACK(complete);
mrq->done_data = &complete;
mrq->done = mmc_wait_done;
mmc_start_request(host, mrq);
wait_for_completion(&complete);
}
EXPORT_SYMBOL(mmc_wait_for_req);
/**
* mmc_wait_for_cmd - start a command and wait for completion
* @host: MMC host to start command
* @cmd: MMC command to start
* @retries: maximum number of retries
*
* Start a new MMC command for a host, and wait for the command
* to complete. Return any error that occurred while the command
* was executing. Do not attempt to parse the response.
*/
int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries)
{
struct mmc_request mrq = {0};
WARN_ON(!host->claimed);
memset(cmd->resp, 0, sizeof(cmd->resp));
cmd->retries = retries;
mrq.cmd = cmd;
cmd->data = NULL;
mmc_wait_for_req(host, &mrq);
return cmd->error;
}
EXPORT_SYMBOL(mmc_wait_for_cmd);
/**
* mmc_set_data_timeout - set the timeout for a data command
* @data: data phase for command
* @card: the MMC card associated with the data transfer
*
* Computes the data timeout parameters according to the
* correct algorithm given the card type.
*/
void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
{
unsigned int mult;
/*
* SDIO cards only define an upper 1 s limit on access.
*/
if (mmc_card_sdio(card)) {
data->timeout_ns = 1000000000;
data->timeout_clks = 0;
return;
}
/*
* SD cards use a 100 multiplier rather than 10
*/
mult = mmc_card_sd(card) ? 100 : 10;
/*
* Scale up the multiplier (and therefore the timeout) by
* the r2w factor for writes.
*/
if (data->flags & MMC_DATA_WRITE)
mult <<= card->csd.r2w_factor;
data->timeout_ns = card->csd.tacc_ns * mult;
data->timeout_clks = card->csd.tacc_clks * mult;
/*
* SD cards also have an upper limit on the timeout.
*/
if (mmc_card_sd(card)) {
unsigned int timeout_us, limit_us;
timeout_us = data->timeout_ns / 1000;
if (mmc_host_clk_rate(card->host))
timeout_us += data->timeout_clks * 1000 /
(mmc_host_clk_rate(card->host) / 1000);
if (data->flags & MMC_DATA_WRITE)
/*
* The limit is really 250 ms, but that is
* insufficient for some crappy cards.
*/
limit_us = 300000;
else
limit_us = 100000;
/*
* SDHC cards always use these fixed values.
*/
if (timeout_us > limit_us || mmc_card_blockaddr(card)) {
data->timeout_ns = limit_us * 1000;
data->timeout_clks = 0;
}
}
/*
* Some cards need very high timeouts if driven in SPI mode.
* The worst observed timeout was 900ms after writing a
* continuous stream of data until the internal logic
* overflowed.
*/
if (mmc_host_is_spi(card->host)) {
if (data->flags & MMC_DATA_WRITE) {
if (data->timeout_ns < 1000000000)
data->timeout_ns = 1000000000; /* 1s */
} else {
if (data->timeout_ns < 100000000)
data->timeout_ns = 100000000; /* 100ms */
}
}
}
EXPORT_SYMBOL(mmc_set_data_timeout);
/**
* mmc_align_data_size - pads a transfer size to a more optimal value
* @card: the MMC card associated with the data transfer
* @sz: original transfer size
*
* Pads the original data size with a number of extra bytes in
* order to avoid controller bugs and/or performance hits
* (e.g. some controllers revert to PIO for certain sizes).
*
* Returns the improved size, which might be unmodified.
*
* Note that this function is only relevant when issuing a
* single scatter gather entry.
*/
unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz)
{
/*
* FIXME: We don't have a system for the controller to tell
* the core about its problems yet, so for now we just 32-bit
* align the size.
*/
sz = ((sz + 3) / 4) * 4;
return sz;
}
EXPORT_SYMBOL(mmc_align_data_size);
/**
* mmc_host_enable - enable a host.
* @host: mmc host to enable
*
* Hosts that support power saving can use the 'enable' and 'disable'
* methods to exit and enter power saving states. For more information
* see comments for struct mmc_host_ops.
*/
int mmc_host_enable(struct mmc_host *host)
{
if (!(host->caps & MMC_CAP_DISABLE))
return 0;
if (host->en_dis_recurs)
return 0;
if (host->nesting_cnt++)
return 0;
cancel_delayed_work_sync(&host->disable);
if (host->enabled)
return 0;
if (host->ops->enable) {
int err;
host->en_dis_recurs = 1;
err = host->ops->enable(host);
host->en_dis_recurs = 0;
if (err) {
pr_debug("%s: enable error %d\n",
mmc_hostname(host), err);
return err;
}
}
host->enabled = 1;
return 0;
}
EXPORT_SYMBOL(mmc_host_enable);
static int mmc_host_do_disable(struct mmc_host *host, int lazy)
{
if (host->ops->disable) {
int err;
host->en_dis_recurs = 1;
err = host->ops->disable(host, lazy);
host->en_dis_recurs = 0;
if (err < 0) {
pr_debug("%s: disable error %d\n",
mmc_hostname(host), err);
return err;
}
if (err > 0) {
unsigned long delay = msecs_to_jiffies(err);
mmc_schedule_delayed_work(&host->disable, delay);
}
}
host->enabled = 0;
return 0;
}
/**
* mmc_host_disable - disable a host.
* @host: mmc host to disable
*
* Hosts that support power saving can use the 'enable' and 'disable'
* methods to exit and enter power saving states. For more information
* see comments for struct mmc_host_ops.
*/
int mmc_host_disable(struct mmc_host *host)
{
int err;
if (!(host->caps & MMC_CAP_DISABLE))
return 0;
if (host->en_dis_recurs)
return 0;
if (--host->nesting_cnt)
return 0;
if (!host->enabled)
return 0;
err = mmc_host_do_disable(host, 0);
return err;
}
EXPORT_SYMBOL(mmc_host_disable);
/**
* __mmc_claim_host - exclusively claim a host
* @host: mmc host to claim
* @abort: whether or not the operation should be aborted
*
* Claim a host for a set of operations. If @abort is non null and
* dereference a non-zero value then this will return prematurely with
* that non-zero value without acquiring the lock. Returns zero
* with the lock held otherwise.
*/
int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)
{
DECLARE_WAITQUEUE(wait, current);
unsigned long flags;
int stop;
might_sleep();
add_wait_queue(&host->wq, &wait);
spin_lock_irqsave(&host->lock, flags);
while (1) {
set_current_state(TASK_UNINTERRUPTIBLE);
stop = abort ? atomic_read(abort) : 0;
if (stop || !host->claimed || host->claimer == current)
break;
spin_unlock_irqrestore(&host->lock, flags);
schedule();
spin_lock_irqsave(&host->lock, flags);
}
set_current_state(TASK_RUNNING);
if (!stop) {
host->claimed = 1;
host->claimer = current;
host->claim_cnt += 1;
} else
wake_up(&host->wq);
spin_unlock_irqrestore(&host->lock, flags);
remove_wait_queue(&host->wq, &wait);
if (!stop)
mmc_host_enable(host);
return stop;
}
EXPORT_SYMBOL(__mmc_claim_host);
/**
* mmc_try_claim_host - try exclusively to claim a host
* @host: mmc host to claim
*
* Returns %1 if the host is claimed, %0 otherwise.
*/
int mmc_try_claim_host(struct mmc_host *host)
{
int claimed_host = 0;
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
if (!host->claimed || host->claimer == current) {
host->claimed = 1;
host->claimer = current;
host->claim_cnt += 1;
claimed_host = 1;
}
spin_unlock_irqrestore(&host->lock, flags);
return claimed_host;
}
EXPORT_SYMBOL(mmc_try_claim_host);
/**
* mmc_do_release_host - release a claimed host
* @host: mmc host to release
*
* If you successfully claimed a host, this function will
* release it again.
*/
void mmc_do_release_host(struct mmc_host *host)
{
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
if (--host->claim_cnt) {
/* Release for nested claim */
spin_unlock_irqrestore(&host->lock, flags);
} else {
host->claimed = 0;
host->claimer = NULL;
spin_unlock_irqrestore(&host->lock, flags);
wake_up(&host->wq);
}
}
EXPORT_SYMBOL(mmc_do_release_host);
void mmc_host_deeper_disable(struct work_struct *work)
{
struct mmc_host *host =
container_of(work, struct mmc_host, disable.work);
/* If the host is claimed then we do not want to disable it anymore */
if (!mmc_try_claim_host(host))
return;
mmc_host_do_disable(host, 1);
mmc_do_release_host(host);
}
/**
* mmc_host_lazy_disable - lazily disable a host.
* @host: mmc host to disable
*
* Hosts that support power saving can use the 'enable' and 'disable'
* methods to exit and enter power saving states. For more information
* see comments for struct mmc_host_ops.
*/
int mmc_host_lazy_disable(struct mmc_host *host)
{
if (!(host->caps & MMC_CAP_DISABLE))
return 0;
if (host->en_dis_recurs)
return 0;
if (--host->nesting_cnt)
return 0;
if (!host->enabled)
return 0;
if (host->disable_delay) {
mmc_schedule_delayed_work(&host->disable,
msecs_to_jiffies(host->disable_delay));
return 0;
} else
return mmc_host_do_disable(host, 1);
}
EXPORT_SYMBOL(mmc_host_lazy_disable);
/**
* mmc_release_host - release a host
* @host: mmc host to release
*
* Release a MMC host, allowing others to claim the host
* for their operations.
*/
void mmc_release_host(struct mmc_host *host)
{
WARN_ON(!host->claimed);
mmc_host_lazy_disable(host);
mmc_do_release_host(host);
}
EXPORT_SYMBOL(mmc_release_host);
/*
* Internal function that does the actual ios call to the host driver,
* optionally printing some debug output.
*/
static inline void mmc_set_ios(struct mmc_host *host)
{
struct mmc_ios *ios = &host->ios;
pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u "
"width %u timing %u\n",
mmc_hostname(host), ios->clock, ios->bus_mode,
ios->power_mode, ios->chip_select, ios->vdd,
ios->bus_width, ios->timing);
if (ios->clock > 0)
mmc_set_ungated(host);
host->ops->set_ios(host, ios);
}
/*
* Control chip select pin on a host.
*/
void mmc_set_chip_select(struct mmc_host *host, int mode)
{
mmc_host_clk_hold(host);
host->ios.chip_select = mode;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Sets the host clock to the highest possible frequency that
* is below "hz".
*/
static void __mmc_set_clock(struct mmc_host *host, unsigned int hz)
{
WARN_ON(hz < host->f_min);
if (hz > host->f_max)
hz = host->f_max;
host->ios.clock = hz;
mmc_set_ios(host);
}
void mmc_set_clock(struct mmc_host *host, unsigned int hz)
{
mmc_host_clk_hold(host);
__mmc_set_clock(host, hz);
mmc_host_clk_release(host);
}
#ifdef CONFIG_MMC_CLKGATE
/*
* This gates the clock by setting it to 0 Hz.
*/
void mmc_gate_clock(struct mmc_host *host)
{
unsigned long flags;
spin_lock_irqsave(&host->clk_lock, flags);
host->clk_old = host->ios.clock;
host->ios.clock = 0;
host->clk_gated = true;
spin_unlock_irqrestore(&host->clk_lock, flags);
mmc_set_ios(host);
}
/*
* This restores the clock from gating by using the cached
* clock value.
*/
void mmc_ungate_clock(struct mmc_host *host)
{
/*
* We should previously have gated the clock, so the clock shall
* be 0 here! The clock may however be 0 during initialization,
* when some request operations are performed before setting
* the frequency. When ungate is requested in that situation
* we just ignore the call.
*/
if (host->clk_old) {
BUG_ON(host->ios.clock);
/* This call will also set host->clk_gated to false */
__mmc_set_clock(host, host->clk_old);
}
}
void mmc_set_ungated(struct mmc_host *host)
{
unsigned long flags;
/*
* We've been given a new frequency while the clock is gated,
* so make sure we regard this as ungating it.
*/
spin_lock_irqsave(&host->clk_lock, flags);
host->clk_gated = false;
spin_unlock_irqrestore(&host->clk_lock, flags);
}
#else
void mmc_set_ungated(struct mmc_host *host)
{
}
#endif
/*
* Change the bus mode (open drain/push-pull) of a host.
*/
void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
{
mmc_host_clk_hold(host);
host->ios.bus_mode = mode;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Change data bus width of a host.
*/
void mmc_set_bus_width(struct mmc_host *host, unsigned int width)
{
mmc_host_clk_hold(host);
host->ios.bus_width = width;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/**
* mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number
* @vdd: voltage (mV)
* @low_bits: prefer low bits in boundary cases
*
* This function returns the OCR bit number according to the provided @vdd
* value. If conversion is not possible a negative errno value returned.
*
* Depending on the @low_bits flag the function prefers low or high OCR bits
* on boundary voltages. For example,
* with @low_bits = true, 3300 mV translates to ilog2(MMC_VDD_32_33);
* with @low_bits = false, 3300 mV translates to ilog2(MMC_VDD_33_34);
*
* Any value in the [1951:1999] range translates to the ilog2(MMC_VDD_20_21).
*/
static int mmc_vdd_to_ocrbitnum(int vdd, bool low_bits)
{
const int max_bit = ilog2(MMC_VDD_35_36);
int bit;
if (vdd < 1650 || vdd > 3600)
return -EINVAL;
if (vdd >= 1650 && vdd <= 1950)
return ilog2(MMC_VDD_165_195);
if (low_bits)
vdd -= 1;
/* Base 2000 mV, step 100 mV, bit's base 8. */
bit = (vdd - 2000) / 100 + 8;
if (bit > max_bit)
return max_bit;
return bit;
}
/**
* mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask
* @vdd_min: minimum voltage value (mV)
* @vdd_max: maximum voltage value (mV)
*
* This function returns the OCR mask bits according to the provided @vdd_min
* and @vdd_max values. If conversion is not possible the function returns 0.
*
* Notes wrt boundary cases:
* This function sets the OCR bits for all boundary voltages, for example
* [3300:3400] range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 |
* MMC_VDD_34_35 mask.
*/
u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
{
u32 mask = 0;
if (vdd_max < vdd_min)
return 0;
/* Prefer high bits for the boundary vdd_max values. */
vdd_max = mmc_vdd_to_ocrbitnum(vdd_max, false);
if (vdd_max < 0)
return 0;
/* Prefer low bits for the boundary vdd_min values. */
vdd_min = mmc_vdd_to_ocrbitnum(vdd_min, true);
if (vdd_min < 0)
return 0;
/* Fill the mask, from max bit to min bit. */
while (vdd_max >= vdd_min)
mask |= 1 << vdd_max--;
return mask;
}
EXPORT_SYMBOL(mmc_vddrange_to_ocrmask);
#ifdef CONFIG_REGULATOR
/**
* mmc_regulator_get_ocrmask - return mask of supported voltages
* @supply: regulator to use
*
* This returns either a negative errno, or a mask of voltages that
* can be provided to MMC/SD/SDIO devices using the specified voltage
* regulator. This would normally be called before registering the
* MMC host adapter.
*/
int mmc_regulator_get_ocrmask(struct regulator *supply)
{
int result = 0;
int count;
int i;
count = regulator_count_voltages(supply);
if (count < 0)
return count;
for (i = 0; i < count; i++) {
int vdd_uV;
int vdd_mV;
vdd_uV = regulator_list_voltage(supply, i);
if (vdd_uV <= 0)
continue;
vdd_mV = vdd_uV / 1000;
result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
}
return result;
}
EXPORT_SYMBOL(mmc_regulator_get_ocrmask);
/**
* mmc_regulator_set_ocr - set regulator to match host->ios voltage
* @mmc: the host to regulate
* @supply: regulator to use
* @vdd_bit: zero for power off, else a bit number (host->ios.vdd)
*
* Returns zero on success, else negative errno.
*
* MMC host drivers may use this to enable or disable a regulator using
* a particular supply voltage. This would normally be called from the
* set_ios() method.
*/
int mmc_regulator_set_ocr(struct mmc_host *mmc,
struct regulator *supply,
unsigned short vdd_bit)
{
int result = 0;
int min_uV, max_uV;
if (vdd_bit) {
int tmp;
int voltage;
/* REVISIT mmc_vddrange_to_ocrmask() may have set some
* bits this regulator doesn't quite support ... don't
* be too picky, most cards and regulators are OK with
* a 0.1V range goof (it's a small error percentage).
*/
tmp = vdd_bit - ilog2(MMC_VDD_165_195);
if (tmp == 0) {
min_uV = 1650 * 1000;
max_uV = 1950 * 1000;
} else {
min_uV = 1900 * 1000 + tmp * 100 * 1000;
max_uV = min_uV + 100 * 1000;
}
/* avoid needless changes to this voltage; the regulator
* might not allow this operation
*/
voltage = regulator_get_voltage(supply);
if (voltage < 0)
result = voltage;
else if (voltage < min_uV || voltage > max_uV)
result = regulator_set_voltage(supply, min_uV, max_uV);
else
result = 0;
if (result == 0 && !mmc->regulator_enabled) {
result = regulator_enable(supply);
if (!result)
mmc->regulator_enabled = true;
}
} else if (mmc->regulator_enabled) {
result = regulator_disable(supply);
if (result == 0)
mmc->regulator_enabled = false;
}
if (result)
dev_err(mmc_dev(mmc),
"could not set regulator OCR (%d)\n", result);
return result;
}
EXPORT_SYMBOL(mmc_regulator_set_ocr);
#endif /* CONFIG_REGULATOR */
/*
* Mask off any voltages we don't support and select
* the lowest voltage
*/
u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
{
int bit;
ocr &= host->ocr_avail;
bit = ffs(ocr);
if (bit) {
bit -= 1;
ocr &= 3 << bit;
mmc_host_clk_hold(host);
host->ios.vdd = bit;
mmc_set_ios(host);
mmc_host_clk_release(host);
} else {
pr_warning("%s: host doesn't support card's voltages\n",
mmc_hostname(host));
ocr = 0;
}
return ocr;
}
int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11)
{
struct mmc_command cmd = {0};
int err = 0;
BUG_ON(!host);
/*
* Send CMD11 only if the request is to switch the card to
* 1.8V signalling.
*/
if ((signal_voltage != MMC_SIGNAL_VOLTAGE_330) && cmd11) {
cmd.opcode = SD_SWITCH_VOLTAGE;
cmd.arg = 0;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(host, &cmd, 0);
if (err)
return err;
if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR))
return -EIO;
}
host->ios.signal_voltage = signal_voltage;
if (host->ops->start_signal_voltage_switch)
err = host->ops->start_signal_voltage_switch(host, &host->ios);
return err;
}
/*
* Select timing parameters for host.
*/
void mmc_set_timing(struct mmc_host *host, unsigned int timing)
{
mmc_host_clk_hold(host);
host->ios.timing = timing;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Select appropriate driver type for host.
*/
void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type)
{
mmc_host_clk_hold(host);
host->ios.drv_type = drv_type;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Apply power to the MMC stack. This is a two-stage process.
* First, we enable power to the card without the clock running.
* We then wait a bit for the power to stabilise. Finally,
* enable the bus drivers and clock to the card.
*
* We must _NOT_ enable the clock prior to power stablising.
*
* If a host does all the power sequencing itself, ignore the
* initial MMC_POWER_UP stage.
*/
static void mmc_power_up(struct mmc_host *host)
{
int bit;
mmc_host_clk_hold(host);
/* If ocr is set, we use it */
if (host->ocr)
bit = ffs(host->ocr) - 1;
else
bit = fls(host->ocr_avail) - 1;
host->ios.vdd = bit;
if (mmc_host_is_spi(host)) {
host->ios.chip_select = MMC_CS_HIGH;
host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
} else {
host->ios.chip_select = MMC_CS_DONTCARE;
host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
}
host->ios.power_mode = MMC_POWER_UP;
host->ios.bus_width = MMC_BUS_WIDTH_1;
host->ios.timing = MMC_TIMING_LEGACY;
mmc_set_ios(host);
/*
* This delay should be sufficient to allow the power supply
* to reach the minimum voltage.
*/
mmc_delay(10);
host->ios.clock = host->f_init;
host->ios.power_mode = MMC_POWER_ON;
mmc_set_ios(host);
/*
* This delay must be at least 74 clock sizes, or 1 ms, or the
* time required to reach a stable voltage.
*/
mmc_delay(10);
mmc_host_clk_release(host);
}
void mmc_power_off(struct mmc_host *host)
{
mmc_host_clk_hold(host);
host->ios.clock = 0;
host->ios.vdd = 0;
/*
* Reset ocr mask to be the highest possible voltage supported for
* this mmc host. This value will be used at next power up.
*/
host->ocr = 1 << (fls(host->ocr_avail) - 1);
if (!mmc_host_is_spi(host)) {
host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
host->ios.chip_select = MMC_CS_DONTCARE;
}
host->ios.power_mode = MMC_POWER_OFF;
host->ios.bus_width = MMC_BUS_WIDTH_1;
host->ios.timing = MMC_TIMING_LEGACY;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Cleanup when the last reference to the bus operator is dropped.
*/
static void __mmc_release_bus(struct mmc_host *host)
{
BUG_ON(!host);
BUG_ON(host->bus_refs);
BUG_ON(!host->bus_dead);
host->bus_ops = NULL;
}
/*
* Increase reference count of bus operator
*/
static inline void mmc_bus_get(struct mmc_host *host)
{
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
host->bus_refs++;
spin_unlock_irqrestore(&host->lock, flags);
}
/*
* Decrease reference count of bus operator and free it if
* it is the last reference.
*/
static inline void mmc_bus_put(struct mmc_host *host)
{
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
host->bus_refs--;
if ((host->bus_refs == 0) && host->bus_ops)
__mmc_release_bus(host);
spin_unlock_irqrestore(&host->lock, flags);
}
int mmc_resume_bus(struct mmc_host *host)
{
unsigned long flags;
int err = 0;
if (!mmc_bus_needs_resume(host))
return -EINVAL;
printk("%s: Starting deferred resume\n", mmc_hostname(host));
spin_lock_irqsave(&host->lock, flags);
host->bus_resume_flags &= ~MMC_BUSRESUME_NEEDS_RESUME;
host->rescan_disable = 0;
spin_unlock_irqrestore(&host->lock, flags);
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
mmc_power_up(host);
BUG_ON(!host->bus_ops->resume);
err = host->bus_ops->resume(host);
}
#ifdef CONFIG_MACH_P1
if (!err) {
#endif
if (host->bus_ops->detect && !host->bus_dead)
host->bus_ops->detect(host);
#ifdef CONFIG_MACH_P1
} else {
printk(KERN_WARNING "%s: error %d during resume "
"(card was removed?)\n",
mmc_hostname(host), err);
}
#endif
mmc_bus_put(host);
printk("%s: Deferred resume completed\n", mmc_hostname(host));
return 0;
}
EXPORT_SYMBOL(mmc_resume_bus);
/*
* Assign a mmc bus handler to a host. Only one bus handler may control a
* host at any given time.
*/
void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
{
unsigned long flags;
BUG_ON(!host);
BUG_ON(!ops);
WARN_ON(!host->claimed);
spin_lock_irqsave(&host->lock, flags);
BUG_ON(host->bus_ops);
BUG_ON(host->bus_refs);
host->bus_ops = ops;
host->bus_refs = 1;
host->bus_dead = 0;
spin_unlock_irqrestore(&host->lock, flags);
}
/*
* Remove the current bus handler from a host.
*/
void mmc_detach_bus(struct mmc_host *host)
{
unsigned long flags;
BUG_ON(!host);
WARN_ON(!host->claimed);
WARN_ON(!host->bus_ops);
spin_lock_irqsave(&host->lock, flags);
host->bus_dead = 1;
spin_unlock_irqrestore(&host->lock, flags);
mmc_bus_put(host);
}
/**
* mmc_detect_change - process change of state on a MMC socket
* @host: host which changed state.
* @delay: optional delay to wait before detection (jiffies)
*
* MMC drivers should call this when they detect a card has been
* inserted or removed. The MMC layer will confirm that any
* present card is still functional, and initialize any newly
* inserted.
*/
void mmc_detect_change(struct mmc_host *host, unsigned long delay)
{
#ifdef CONFIG_MMC_DEBUG
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
WARN_ON(host->removed);
spin_unlock_irqrestore(&host->lock, flags);
#endif
wake_lock(&host->detect_wake_lock);
mmc_schedule_delayed_work(&host->detect, delay);
}
EXPORT_SYMBOL(mmc_detect_change);
void mmc_init_erase(struct mmc_card *card)
{
unsigned int sz;
if (is_power_of_2(card->erase_size))
card->erase_shift = ffs(card->erase_size) - 1;
else
card->erase_shift = 0;
/*
* It is possible to erase an arbitrarily large area of an SD or MMC
* card. That is not desirable because it can take a long time
* (minutes) potentially delaying more important I/O, and also the
* timeout calculations become increasingly hugely over-estimated.
* Consequently, 'pref_erase' is defined as a guide to limit erases
* to that size and alignment.
*
* For SD cards that define Allocation Unit size, limit erases to one
* Allocation Unit at a time. For MMC cards that define High Capacity
* Erase Size, whether it is switched on or not, limit to that size.
* Otherwise just have a stab at a good value. For modern cards it
* will end up being 4MiB. Note that if the value is too small, it
* can end up taking longer to erase.
*/
if (mmc_card_sd(card) && card->ssr.au) {
card->pref_erase = card->ssr.au;
card->erase_shift = ffs(card->ssr.au) - 1;
} else if (card->ext_csd.hc_erase_size) {
card->pref_erase = card->ext_csd.hc_erase_size;
} else {
sz = (card->csd.capacity << (card->csd.read_blkbits - 9)) >> 11;
if (sz < 128)
card->pref_erase = 512 * 1024 / 512;
else if (sz < 512)
card->pref_erase = 1024 * 1024 / 512;
else if (sz < 1024)
card->pref_erase = 2 * 1024 * 1024 / 512;
else
card->pref_erase = 4 * 1024 * 1024 / 512;
if (card->pref_erase < card->erase_size)
card->pref_erase = card->erase_size;
else {
sz = card->pref_erase % card->erase_size;
if (sz)
card->pref_erase += card->erase_size - sz;
}
}
}
static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
unsigned int arg, unsigned int qty)
{
unsigned int erase_timeout;
if (card->ext_csd.erase_group_def & 1) {
/* High Capacity Erase Group Size uses HC timeouts */
if (arg == MMC_TRIM_ARG)
erase_timeout = card->ext_csd.trim_timeout;
else
erase_timeout = card->ext_csd.hc_erase_timeout;
} else {
/* CSD Erase Group Size uses write timeout */
unsigned int mult = (10 << card->csd.r2w_factor);
unsigned int timeout_clks = card->csd.tacc_clks * mult;
unsigned int timeout_us;
/* Avoid overflow: e.g. tacc_ns=80000000 mult=1280 */
if (card->csd.tacc_ns < 1000000)
timeout_us = (card->csd.tacc_ns * mult) / 1000;
else
timeout_us = (card->csd.tacc_ns / 1000) * mult;
/*
* ios.clock is only a target. The real clock rate might be
* less but not that much less, so fudge it by multiplying by 2.
*/
timeout_clks <<= 1;
timeout_us += (timeout_clks * 1000) /
(mmc_host_clk_rate(card->host) / 1000);
erase_timeout = timeout_us / 1000;
/*
* Theoretically, the calculation could underflow so round up
* to 1ms in that case.
*/
if (!erase_timeout)
erase_timeout = 1;
}
/* Multiplier for secure operations */
if (arg & MMC_SECURE_ARGS) {
if (arg == MMC_SECURE_ERASE_ARG)
erase_timeout *= card->ext_csd.sec_erase_mult;
else
erase_timeout *= card->ext_csd.sec_trim_mult;
}
erase_timeout *= qty;
/*
* Ensure at least a 1 second timeout for SPI as per
* 'mmc_set_data_timeout()'
*/
if (mmc_host_is_spi(card->host) && erase_timeout < 1000)
erase_timeout = 1000;
return erase_timeout;
}
static unsigned int mmc_sd_erase_timeout(struct mmc_card *card,
unsigned int arg,
unsigned int qty)
{
unsigned int erase_timeout;
if (card->ssr.erase_timeout) {
/* Erase timeout specified in SD Status Register (SSR) */
erase_timeout = card->ssr.erase_timeout * qty +
card->ssr.erase_offset;
} else {
/*
* Erase timeout not specified in SD Status Register (SSR) so
* use 250ms per write block.
*/
erase_timeout = 250 * qty;
}
/* Must not be less than 1 second */
if (erase_timeout < 1000)
erase_timeout = 1000;
return erase_timeout;
}
static unsigned int mmc_erase_timeout(struct mmc_card *card,
unsigned int arg,
unsigned int qty)
{
if (mmc_card_sd(card))
return mmc_sd_erase_timeout(card, arg, qty);
else
return mmc_mmc_erase_timeout(card, arg, qty);
}
static int mmc_do_erase(struct mmc_card *card, unsigned int from,
unsigned int to, unsigned int arg)
{
struct mmc_command cmd = {0};
unsigned int qty = 0;
int err;
/*
* qty is used to calculate the erase timeout which depends on how many
* erase groups (or allocation units in SD terminology) are affected.
* We count erasing part of an erase group as one erase group.
* For SD, the allocation units are always a power of 2. For MMC, the
* erase group size is almost certainly also power of 2, but it does not
* seem to insist on that in the JEDEC standard, so we fall back to
* division in that case. SD may not specify an allocation unit size,
* in which case the timeout is based on the number of write blocks.
*
* Note that the timeout for secure trim 2 will only be correct if the
* number of erase groups specified is the same as the total of all
* preceding secure trim 1 commands. Since the power may have been
* lost since the secure trim 1 commands occurred, it is generally
* impossible to calculate the secure trim 2 timeout correctly.
*/
if (card->erase_shift)
qty += ((to >> card->erase_shift) -
(from >> card->erase_shift)) + 1;
else if (mmc_card_sd(card))
qty += to - from + 1;
else
qty += ((to / card->erase_size) -
(from / card->erase_size)) + 1;
if (!mmc_card_blockaddr(card)) {
from <<= 9;
to <<= 9;
}
if (mmc_card_sd(card))
cmd.opcode = SD_ERASE_WR_BLK_START;
else
cmd.opcode = MMC_ERASE_GROUP_START;
cmd.arg = from;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err) {
printk(KERN_ERR "mmc_erase: group start error %d, "
"status %#x\n", err, cmd.resp[0]);
err = -EINVAL;
goto out;
}
memset(&cmd, 0, sizeof(struct mmc_command));
if (mmc_card_sd(card))
cmd.opcode = SD_ERASE_WR_BLK_END;
else
cmd.opcode = MMC_ERASE_GROUP_END;
cmd.arg = to;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err) {
printk(KERN_ERR "mmc_erase: group end error %d, status %#x\n",
err, cmd.resp[0]);
err = -EINVAL;
goto out;
}
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_ERASE;
cmd.arg = arg;
cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
cmd.cmd_timeout_ms = mmc_erase_timeout(card, arg, qty);
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err) {
printk(KERN_ERR "mmc_erase: erase error %d, status %#x\n",
err, cmd.resp[0]);
err = -EIO;
goto out;
}
if (mmc_host_is_spi(card->host))
goto out;
do {
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SEND_STATUS;
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
/* Do not retry else we can't see errors */
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err || (cmd.resp[0] & 0xFDF92000)) {
printk(KERN_ERR "error %d requesting status %#x\n",
err, cmd.resp[0]);
err = -EIO;
goto out;
}
} while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||
R1_CURRENT_STATE(cmd.resp[0]) == 7);
out:
return err;
}
/**
* mmc_erase - erase sectors.
* @card: card to erase
* @from: first sector to erase
* @nr: number of sectors to erase
* @arg: erase command argument (SD supports only %MMC_ERASE_ARG)
*
* Caller must claim host before calling this function.
*/
int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
unsigned int arg)
{
unsigned int rem, to = from + nr;
if (!(card->host->caps & MMC_CAP_ERASE) ||
!(card->csd.cmdclass & CCC_ERASE))
return -EOPNOTSUPP;
if (!card->erase_size)
return -EOPNOTSUPP;
if (mmc_card_sd(card) && arg != MMC_ERASE_ARG)
return -EOPNOTSUPP;
if ((arg & MMC_SECURE_ARGS) &&
!(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN))
return -EOPNOTSUPP;
if ((arg & MMC_TRIM_ARGS) &&
!(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN))
return -EOPNOTSUPP;
if (arg == MMC_SECURE_ERASE_ARG) {
if (from % card->erase_size || nr % card->erase_size)
return -EINVAL;
}
if (arg == MMC_ERASE_ARG) {
rem = from % card->erase_size;
if (rem) {
rem = card->erase_size - rem;
from += rem;
if (nr > rem)
nr -= rem;
else
return 0;
}
rem = nr % card->erase_size;
if (rem)
nr -= rem;
}
if (nr == 0)
return 0;
to = from + nr;
if (to <= from)
return -EINVAL;
/* 'from' and 'to' are inclusive */
to -= 1;
return mmc_do_erase(card, from, to, arg);
}
EXPORT_SYMBOL(mmc_erase);
int mmc_can_erase(struct mmc_card *card)
{
if ((card->host->caps & MMC_CAP_ERASE) &&
(card->csd.cmdclass & CCC_ERASE) && card->erase_size)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_erase);
int mmc_can_trim(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_trim);
int mmc_can_secure_erase_trim(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_secure_erase_trim);
int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
unsigned int nr)
{
if (!card->erase_size)
return 0;
if (from % card->erase_size || nr % card->erase_size)
return 0;
return 1;
}
EXPORT_SYMBOL(mmc_erase_group_aligned);
int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen)
{
struct mmc_command cmd = {0};
if (mmc_card_blockaddr(card) || mmc_card_ddr_mode(card))
return 0;
cmd.opcode = MMC_SET_BLOCKLEN;
cmd.arg = blocklen;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
return mmc_wait_for_cmd(card->host, &cmd, 5);
}
EXPORT_SYMBOL(mmc_set_blocklen);
static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
{
host->f_init = freq;
#ifdef CONFIG_MMC_DEBUG
pr_info("%s: %s: trying to init card at %u Hz\n",
mmc_hostname(host), __func__, host->f_init);
#endif
mmc_power_up(host);
/*
* sdio_reset sends CMD52 to reset card. Since we do not know
* if the card is being re-initialized, just send it. CMD52
* should be ignored by SD/eMMC cards.
*/
sdio_reset(host);
mmc_go_idle(host);
mmc_send_if_cond(host, host->ocr_avail);
/* Order's important: probe SDIO, then SD, then MMC */
if (!mmc_attach_sdio(host))
return 0;
if (!mmc_attach_sd(host))
return 0;
if (!mmc_attach_mmc(host))
return 0;
mmc_power_off(host);
return -EIO;
}
void mmc_rescan(struct work_struct *work)
{
static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
struct mmc_host *host =
container_of(work, struct mmc_host, detect.work);
int i;
bool extend_wakelock = false;
if (host->rescan_disable)
return;
mmc_bus_get(host);
/*
* if there is a _removable_ card registered, check whether it is
* still present
*/
if (host->bus_ops && host->bus_ops->detect && !host->bus_dead
&& !(host->caps & MMC_CAP_NONREMOVABLE))
host->bus_ops->detect(host);
/* If the card was removed the bus will be marked
* as dead - extend the wakelock so userspace
* can respond */
if (host->bus_dead)
extend_wakelock = 1;
/*
* Let mmc_bus_put() free the bus/bus_ops if we've found that
* the card is no longer present.
*/
mmc_bus_put(host);
mmc_bus_get(host);
/* if there still is a card present, stop here */
if (host->bus_ops != NULL) {
mmc_bus_put(host);
goto out;
}
/*
* Only we can add a new handler, so it's safe to
* release the lock here.
*/
mmc_bus_put(host);
if (host->ops->get_cd && host->ops->get_cd(host) == 0)
goto out;
mmc_claim_host(host);
for (i = 0; i < ARRAY_SIZE(freqs); i++) {
if (!mmc_rescan_try_freq(host, max(freqs[i], host->f_min))) {
extend_wakelock = true;
break;
}
if (freqs[i] <= host->f_min)
break;
}
mmc_release_host(host);
out:
#if defined(CONFIG_MACH_P1)
wake_lock_timeout(&host->detect_wake_lock, 3*HZ);
#else
if (extend_wakelock)
wake_lock_timeout(&host->detect_wake_lock, HZ / 2);
else
wake_unlock(&host->detect_wake_lock);
#endif
if (host->caps & MMC_CAP_NEEDS_POLL) {
wake_lock(&host->detect_wake_lock);
mmc_schedule_delayed_work(&host->detect, HZ);
}
}
void mmc_start_host(struct mmc_host *host)
{
mmc_power_off(host);
mmc_detect_change(host, 0);
}
void mmc_stop_host(struct mmc_host *host)
{
#ifdef CONFIG_MMC_DEBUG
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
host->removed = 1;
spin_unlock_irqrestore(&host->lock, flags);
#endif
if (host->caps & MMC_CAP_DISABLE)
cancel_delayed_work(&host->disable);
if (cancel_delayed_work_sync(&host->detect))
wake_unlock(&host->detect_wake_lock);
mmc_flush_scheduled_work();
/* clear pm flags now and let card drivers set them as needed */
host->pm_flags = 0;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
if (host->bus_ops->remove)
host->bus_ops->remove(host);
mmc_claim_host(host);
mmc_detach_bus(host);
mmc_power_off(host);
mmc_release_host(host);
mmc_bus_put(host);
return;
}
mmc_bus_put(host);
BUG_ON(host->card);
mmc_power_off(host);
}
int mmc_power_save_host(struct mmc_host *host)
{
int ret = 0;
mmc_bus_get(host);
if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) {
mmc_bus_put(host);
return -EINVAL;
}
if (host->bus_ops->power_save)
ret = host->bus_ops->power_save(host);
mmc_bus_put(host);
mmc_power_off(host);
return ret;
}
EXPORT_SYMBOL(mmc_power_save_host);
int mmc_power_restore_host(struct mmc_host *host)
{
int ret;
mmc_bus_get(host);
if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) {
mmc_bus_put(host);
return -EINVAL;
}
mmc_power_up(host);
ret = host->bus_ops->power_restore(host);
mmc_bus_put(host);
return ret;
}
EXPORT_SYMBOL(mmc_power_restore_host);
int mmc_card_awake(struct mmc_host *host)
{
int err = -ENOSYS;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead && host->bus_ops->awake)
err = host->bus_ops->awake(host);
mmc_bus_put(host);
return err;
}
EXPORT_SYMBOL(mmc_card_awake);
int mmc_card_sleep(struct mmc_host *host)
{
int err = -ENOSYS;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead && host->bus_ops->awake)
err = host->bus_ops->sleep(host);
mmc_bus_put(host);
return err;
}
EXPORT_SYMBOL(mmc_card_sleep);
int mmc_card_can_sleep(struct mmc_host *host)
{
struct mmc_card *card = host->card;
if (card && mmc_card_mmc(card) && card->ext_csd.rev >= 3)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_card_can_sleep);
#ifdef CONFIG_PM
/**
* mmc_suspend_host - suspend a host
* @host: mmc host
*/
int mmc_suspend_host(struct mmc_host *host)
{
int err = 0;
if (mmc_bus_needs_resume(host))
return 0;
if (host->caps & MMC_CAP_DISABLE)
cancel_delayed_work(&host->disable);
if (cancel_delayed_work(&host->detect))
wake_unlock(&host->detect_wake_lock);
mmc_flush_scheduled_work();
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
if (host->bus_ops->suspend)
err = host->bus_ops->suspend(host);
if (err == -ENOSYS || !host->bus_ops->resume) {
/*
* We simply "remove" the card in this case.
* It will be redetected on resume.
*/
if (host->bus_ops->remove)
host->bus_ops->remove(host);
mmc_claim_host(host);
mmc_detach_bus(host);
mmc_power_off(host);
mmc_release_host(host);
host->pm_flags = 0;
err = 0;
}
}
mmc_bus_put(host);
if (!err && !mmc_card_keep_power(host))
mmc_power_off(host);
return err;
}
EXPORT_SYMBOL(mmc_suspend_host);
/**
* mmc_resume_host - resume a previously suspended host
* @host: mmc host
*/
int mmc_resume_host(struct mmc_host *host)
{
int err = 0;
mmc_bus_get(host);
if (mmc_bus_manual_resume(host)) {
host->bus_resume_flags |= MMC_BUSRESUME_NEEDS_RESUME;
mmc_bus_put(host);
return 0;
}
if (host->bus_ops && !host->bus_dead) {
if (!mmc_card_keep_power(host)) {
mmc_power_up(host);
mmc_select_voltage(host, host->ocr);
/*
* Tell runtime PM core we just powered up the card,
* since it still believes the card is powered off.
* Note that currently runtime PM is only enabled
* for SDIO cards that are MMC_CAP_POWER_OFF_CARD
*/
if (mmc_card_sdio(host->card) &&
(host->caps & MMC_CAP_POWER_OFF_CARD)) {
pm_runtime_disable(&host->card->dev);
pm_runtime_set_active(&host->card->dev);
pm_runtime_enable(&host->card->dev);
}
}
BUG_ON(!host->bus_ops->resume);
err = host->bus_ops->resume(host);
if (err) {
printk(KERN_WARNING "%s: error %d during resume "
"(card was removed?)\n",
mmc_hostname(host), err);
err = 0;
}
}
host->pm_flags &= ~MMC_PM_KEEP_POWER;
mmc_bus_put(host);
return err;
}
EXPORT_SYMBOL(mmc_resume_host);
/* Do the card removal on suspend if card is assumed removeable
* Do that in pm notifier while userspace isn't yet frozen, so we will be able
to sync the card.
*/
int mmc_pm_notify(struct notifier_block *notify_block,
unsigned long mode, void *unused)
{
struct mmc_host *host = container_of(
notify_block, struct mmc_host, pm_notify);
unsigned long flags;
switch (mode) {
case PM_HIBERNATION_PREPARE:
case PM_SUSPEND_PREPARE:
spin_lock_irqsave(&host->lock, flags);
if (mmc_bus_needs_resume(host)) {
spin_unlock_irqrestore(&host->lock, flags);
break;
}
host->rescan_disable = 1;
spin_unlock_irqrestore(&host->lock, flags);
if (cancel_delayed_work_sync(&host->detect))
wake_unlock(&host->detect_wake_lock);
if (!host->bus_ops || host->bus_ops->suspend)
break;
mmc_claim_host(host);
if (host->bus_ops->remove)
host->bus_ops->remove(host);
mmc_detach_bus(host);
mmc_power_off(host);
mmc_release_host(host);
host->pm_flags = 0;
break;
case PM_POST_SUSPEND:
case PM_POST_HIBERNATION:
case PM_POST_RESTORE:
spin_lock_irqsave(&host->lock, flags);
if (mmc_bus_manual_resume(host)) {
spin_unlock_irqrestore(&host->lock, flags);
break;
}
host->rescan_disable = 0;
spin_unlock_irqrestore(&host->lock, flags);
mmc_detect_change(host, 0);
}
return 0;
}
#endif
#ifdef CONFIG_MMC_EMBEDDED_SDIO
void mmc_set_embedded_sdio_data(struct mmc_host *host,
struct sdio_cis *cis,
struct sdio_cccr *cccr,
struct sdio_embedded_func *funcs,
int num_funcs)
{
host->embedded_sdio_data.cis = cis;
host->embedded_sdio_data.cccr = cccr;
host->embedded_sdio_data.funcs = funcs;
host->embedded_sdio_data.num_funcs = num_funcs;
}
EXPORT_SYMBOL(mmc_set_embedded_sdio_data);
#endif
static int __init mmc_init(void)
{
int ret;
workqueue = alloc_ordered_workqueue("kmmcd", 0);
if (!workqueue)
return -ENOMEM;
ret = mmc_register_bus();
if (ret)
goto destroy_workqueue;
ret = mmc_register_host_class();
if (ret)
goto unregister_bus;
ret = sdio_register_bus();
if (ret)
goto unregister_host_class;
return 0;
unregister_host_class:
mmc_unregister_host_class();
unregister_bus:
mmc_unregister_bus();
destroy_workqueue:
destroy_workqueue(workqueue);
return ret;
}
static void __exit mmc_exit(void)
{
sdio_unregister_bus();
mmc_unregister_host_class();
mmc_unregister_bus();
destroy_workqueue(workqueue);
}
subsys_initcall(mmc_init);
module_exit(mmc_exit);
MODULE_LICENSE("GPL");
|
sch2307/android_kernel_samsung_aries-kor
|
drivers/mmc/core/core.c
|
C
|
gpl-2.0
| 48,653 |
/**
* Copyright 2009 The Apache Software Foundation
*
* 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.hbase.mymapreduce;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableRecordReader;
import org.apache.hadoop.hbase.mapreduce.TableSplit;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.mapreduce.InputFormat;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
/**
* A base for {@link TableInputFormat}s. Receives a {@link HTable}, an
* {@link Scan} instance that defines the input columns etc. Subclasses may use
* other TableRecordReader implementations.
* <p>
* An example of a subclass:
*
* <pre>
* class ExampleTIF extends TableInputFormatBase implements JobConfigurable {
*
* public void configure(JobConf job) {
* HTable exampleTable = new HTable(HBaseConfiguration.create(job),
* Bytes.toBytes("exampleTable"));
* // mandatory
* setHTable(exampleTable);
* Text[] inputColumns = new byte[][] { Bytes.toBytes("columnA"),
* Bytes.toBytes("columnB") };
* // mandatory
* setInputColumns(inputColumns);
* RowFilterInterface exampleFilter = new RegExpRowFilter("keyPrefix.*");
* // optional
* setRowFilter(exampleFilter);
* }
*
* public void validateInput(JobConf job) throws IOException {
* }
* }
* </pre>
*/
public abstract class TableInputFormatBase extends
InputFormat<ImmutableBytesWritable, Result> {
final Log LOG = LogFactory.getLog(TableInputFormatBase.class);
/** Holds the details for the internal scanner. */
private Scan scan1 = null;
private Scan scan2 = null;
/** The table to scan. */
private HTable table1 = null;
private HTable table2 = null;
/** The reader scanning the table, can be a custom one. */
private TableRecordReader tableRecordReader = null;
/**
* Builds a TableRecordReader. If no TableRecordReader was provided, uses
* the default.
*
* @param split
* The split to work with.
* @param context
* The current context.
* @return The newly created record reader.
* @throws IOException
* When creating the reader fails.
* @see org.apache.hadoop.mapreduce.InputFormat#createRecordReader(org.apache.hadoop.mapreduce.InputSplit,
* org.apache.hadoop.mapreduce.TaskAttemptContext)
*/
@Override
public RecordReader<ImmutableBytesWritable, Result> createRecordReader(
InputSplit split, TaskAttemptContext context) throws IOException {
if (table1 == null) {
throw new IOException(
"Cannot create a record reader because of a"
+ " previous error. Please look at the previous logs lines from"
+ " the task's full log for more details.");
}
TableSplit tSplit = (TableSplit) split;
TableRecordReader trr = this.tableRecordReader;
// if no table record reader was provided use default
if (trr == null) {
trr = new TableRecordReader();
}
if ( tSplit.getTableName().length == table1.getTableName().length ) {
Scan sc = new Scan(this.scan1);
sc.setStartRow(tSplit.getStartRow());
sc.setStopRow(tSplit.getEndRow());
trr.setScan(sc);
trr.setHTable(table1);
} else {
if (table2 == null) {
throw new IOException(
"Cannot create a record reader because of a"
+ " previous error. Please look at the previous logs lines from"
+ " the task's full log for more details.");
}
Scan sc = new Scan(this.scan2);
sc.setStartRow(tSplit.getStartRow());
sc.setStopRow(tSplit.getEndRow());
trr.setScan(sc);
trr.setHTable(table2);
}
trr.init();
return trr;
}
/**
* Calculates the splits that will serve as input for the map tasks. The
* number of splits matches the number of regions in a table.
*
* @param context
* The current job context.
* @return The list of input splits.
* @throws IOException
* When creating the list of splits fails.
* @see org.apache.hadoop.mapreduce.InputFormat#getSplits(org.apache.hadoop.mapreduce.JobContext)
*/
void setSplitsForTable(HTable tTable, Scan tScan, List<InputSplit> splits)
throws IOException {
if (tTable == null) {
throw new IOException("No table was provided.");
}
Pair<byte[][], byte[][]> keys = tTable.getStartEndKeys();
if (keys == null || keys.getFirst() == null
|| keys.getFirst().length == 0) {
throw new IOException("Expecting at least one region.");
}
int count = 0;
for (int i = 0; i < keys.getFirst().length; i++) {
if (!includeRegionInSplit(keys.getFirst()[i], keys.getSecond()[i])) {
continue;
}
String regionLocation = tTable.getRegionLocation(keys.getFirst()[i]).getHostname();
byte[] startRow = tScan.getStartRow();
byte[] stopRow = tScan.getStopRow();
// determine if the given start an stop key fall into the region
if ((startRow.length == 0 || keys.getSecond()[i].length == 0 || Bytes
.compareTo(startRow, keys.getSecond()[i]) < 0)
&& (stopRow.length == 0 || Bytes.compareTo(stopRow,
keys.getFirst()[i]) > 0)) {
byte[] splitStart = startRow.length == 0
|| Bytes.compareTo(keys.getFirst()[i], startRow) >= 0 ? keys
.getFirst()[i] : startRow;
byte[] splitStop = (stopRow.length == 0 || Bytes.compareTo(
keys.getSecond()[i], stopRow) <= 0)
&& keys.getSecond()[i].length > 0 ? keys.getSecond()[i]
: stopRow;
InputSplit split = new TableSplit(tTable.getTableName(),
splitStart, splitStop, regionLocation);
splits.add(split);
if (LOG.isDebugEnabled())
LOG.debug("getSplits: split -> " + (count++) + " -> "
+ split);
}
}
}
@Override
public List<InputSplit> getSplits(JobContext context) throws IOException {
List<InputSplit> splits = new ArrayList<InputSplit>();
setSplitsForTable(table1, scan1, splits);
if(table2 != null){
setSplitsForTable(table2, scan2, splits);
}
return splits;
}
/**
*
*
* Test if the given region is to be included in the InputSplit while
* splitting the regions of a table.
* <p>
* This optimization is effective when there is a specific reasoning to
* exclude an entire region from the M-R job, (and hence, not contributing
* to the InputSplit), given the start and end keys of the same. <br>
* Useful when we need to remember the last-processed top record and revisit
* the [last, current) inter4val for M-R processing, continuously. In
* addition to reducing InputSplits, reduces the load on the region server
* as well, due to the ordering of the keys. <br>
* <br>
* Note: It is possible that <code>endKey.length() == 0 </code> , for the
* last (recent) region. <br>
* Override this method, if you want to bulk exclude regions altogether from
* M-R. By default, no region is excluded( i.e. all regions are included).
*
*
* @param startKey
* Start key of the region
* @param endKey
* End key of the region
* @return true, if this region needs to be included as part of the input
* (default).
*
*/
protected boolean includeRegionInSplit(final byte[] startKey,
final byte[] endKey) {
return true;
}
/**
* Allows subclasses to get the {@link HTable}.
*/
protected HTable getHTable1() {
return this.table1;
}
/**
* Allows subclasses to set the {@link HTable}.
*
* @param table
* The table to get the data from.
*/
protected void setHTable1(HTable table) {
this.table1 = table;
}
protected void setHTable2(HTable table) {
this.table2 = table;
}
/**
* Gets the scan defining the actual details like columns etc.
*
* @return The internal scan instance.
*/
public Scan getScan1() {
if (this.scan1 == null)
this.scan1 = new Scan();
return scan1;
}
public Scan getScan2() {
if (this.scan2 == null)
this.scan2 = new Scan();
return scan2;
}
/**
* Sets the scan defining the actual details like columns etc.
*
* @param scan
* The scan to set.
*/
public void setScan(Scan scan1, Scan scan2) {
this.scan1 = scan1;
this.scan2 = scan2;
}
/**
* Allows subclasses to set the {@link TableRecordReader}.
*
* @param tableRecordReader
* A different {@link TableRecordReader} implementation.
*/
protected void setTableRecordReader(TableRecordReader tableRecordReader) {
this.tableRecordReader = tableRecordReader;
}
}
|
lifeng5042/RStore
|
src/org/apache/hadoop/hbase/mymapreduce/TableInputFormatBase.java
|
Java
|
gpl-2.0
| 9,657 |
/* cnic.h: Broadcom CNIC core network driver.
*
* Copyright (c) 2006-2010 Broadcom Corporation
*
* 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.
*
*/
#ifndef CNIC_H
#define CNIC_H
#define HC_INDEX_ISCSI_EQ_CONS 6
#define HC_INDEX_FCOE_EQ_CONS 3
#define HC_SP_INDEX_ETH_ISCSI_CQ_CONS 5
#define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS 1
#define KWQ_PAGE_CNT 4
#define KCQ_PAGE_CNT 16
#define KWQ_CID 24
#define KCQ_CID 25
/*
* krnlq_context definition
*/
#define L5_KRNLQ_FLAGS 0x00000000
#define L5_KRNLQ_SIZE 0x00000000
#define L5_KRNLQ_TYPE 0x00000000
#define KRNLQ_FLAGS_PG_SZ (0xf<<0)
#define KRNLQ_FLAGS_PG_SZ_256 (0<<0)
#define KRNLQ_FLAGS_PG_SZ_512 (1<<0)
#define KRNLQ_FLAGS_PG_SZ_1K (2<<0)
#define KRNLQ_FLAGS_PG_SZ_2K (3<<0)
#define KRNLQ_FLAGS_PG_SZ_4K (4<<0)
#define KRNLQ_FLAGS_PG_SZ_8K (5<<0)
#define KRNLQ_FLAGS_PG_SZ_16K (6<<0)
#define KRNLQ_FLAGS_PG_SZ_32K (7<<0)
#define KRNLQ_FLAGS_PG_SZ_64K (8<<0)
#define KRNLQ_FLAGS_PG_SZ_128K (9<<0)
#define KRNLQ_FLAGS_PG_SZ_256K (10<<0)
#define KRNLQ_FLAGS_PG_SZ_512K (11<<0)
#define KRNLQ_FLAGS_PG_SZ_1M (12<<0)
#define KRNLQ_FLAGS_PG_SZ_2M (13<<0)
#define KRNLQ_FLAGS_QE_SELF_SEQ (1<<15)
#define KRNLQ_SIZE_TYPE_SIZE ((((0x28 + 0x1f) & ~0x1f) / 0x20) << 16)
#define KRNLQ_TYPE_TYPE (0xf<<28)
#define KRNLQ_TYPE_TYPE_EMPTY (0<<28)
#define KRNLQ_TYPE_TYPE_KRNLQ (6<<28)
#define L5_KRNLQ_HOST_QIDX 0x00000004
#define L5_KRNLQ_HOST_FW_QIDX 0x00000008
#define L5_KRNLQ_NX_QE_SELF_SEQ 0x0000000c
#define L5_KRNLQ_QE_SELF_SEQ_MAX 0x0000000c
#define L5_KRNLQ_NX_QE_HADDR_HI 0x00000010
#define L5_KRNLQ_NX_QE_HADDR_LO 0x00000014
#define L5_KRNLQ_PGTBL_PGIDX 0x00000018
#define L5_KRNLQ_NX_PG_QIDX 0x00000018
#define L5_KRNLQ_PGTBL_NPAGES 0x0000001c
#define L5_KRNLQ_QIDX_INCR 0x0000001c
#define L5_KRNLQ_PGTBL_HADDR_HI 0x00000020
#define L5_KRNLQ_PGTBL_HADDR_LO 0x00000024
#define BNX2_PG_CTX_MAP 0x1a0034
#define BNX2_ISCSI_CTX_MAP 0x1a0074
struct cnic_redirect_entry {
struct dst_entry *old_dst;
struct dst_entry *new_dst;
};
#define MAX_COMPLETED_KCQE 64
#define MAX_CNIC_L5_CONTEXT 256
#define MAX_CM_SK_TBL_SZ MAX_CNIC_L5_CONTEXT
#define MAX_ISCSI_TBL_SZ 256
#define CNIC_LOCAL_PORT_MIN 60000
#define CNIC_LOCAL_PORT_MAX 61024
#define CNIC_LOCAL_PORT_RANGE (CNIC_LOCAL_PORT_MAX - CNIC_LOCAL_PORT_MIN)
#define KWQE_CNT (BCM_PAGE_SIZE / sizeof(struct kwqe))
#define KCQE_CNT (BCM_PAGE_SIZE / sizeof(struct kcqe))
#define MAX_KWQE_CNT (KWQE_CNT - 1)
#define MAX_KCQE_CNT (KCQE_CNT - 1)
#define MAX_KWQ_IDX ((KWQ_PAGE_CNT * KWQE_CNT) - 1)
#define MAX_KCQ_IDX ((KCQ_PAGE_CNT * KCQE_CNT) - 1)
#define KWQ_PG(x) (((x) & ~MAX_KWQE_CNT) >> (BCM_PAGE_BITS - 5))
#define KWQ_IDX(x) ((x) & MAX_KWQE_CNT)
#define KCQ_PG(x) (((x) & ~MAX_KCQE_CNT) >> (BCM_PAGE_BITS - 5))
#define KCQ_IDX(x) ((x) & MAX_KCQE_CNT)
#define BNX2X_NEXT_KCQE(x) (((x) & (MAX_KCQE_CNT - 1)) == \
(MAX_KCQE_CNT - 1)) ? \
(x) + 2 : (x) + 1
#define BNX2X_KWQ_DATA_PG(cp, x) ((x) / (cp)->kwq_16_data_pp)
#define BNX2X_KWQ_DATA_IDX(cp, x) ((x) % (cp)->kwq_16_data_pp)
#define BNX2X_KWQ_DATA(cp, x) \
&(cp)->kwq_16_data[BNX2X_KWQ_DATA_PG(cp, x)][BNX2X_KWQ_DATA_IDX(cp, x)]
#define DEF_IPID_START 0x8000
#define DEF_KA_TIMEOUT 10000
#define DEF_KA_INTERVAL 300000
#define DEF_KA_MAX_PROBE_COUNT 3
#define DEF_TOS 0
#define DEF_TTL 0xfe
#define DEF_SND_SEQ_SCALE 0
#define DEF_RCV_BUF 0xffff
#define DEF_SND_BUF 0xffff
#define DEF_SEED 0
#define DEF_MAX_RT_TIME 500
#define DEF_MAX_DA_COUNT 2
#define DEF_SWS_TIMER 1000
#define DEF_MAX_CWND 0xffff
struct cnic_ctx {
u32 cid;
void *ctx;
dma_addr_t mapping;
};
#define BNX2_MAX_CID 0x2000
struct cnic_dma {
int num_pages;
void **pg_arr;
dma_addr_t *pg_map_arr;
int pgtbl_size;
u32 *pgtbl;
dma_addr_t pgtbl_map;
};
struct cnic_id_tbl {
spinlock_t lock;
u32 start;
u32 max;
u32 next;
unsigned long *table;
};
#define CNIC_KWQ16_DATA_SIZE 128
struct kwqe_16_data {
u8 data[CNIC_KWQ16_DATA_SIZE];
};
struct cnic_iscsi {
struct cnic_dma task_array_info;
struct cnic_dma r2tq_info;
struct cnic_dma hq_info;
};
struct cnic_context {
u32 cid;
struct kwqe_16_data *kwqe_data;
dma_addr_t kwqe_data_mapping;
wait_queue_head_t waitq;
int wait_cond;
unsigned long timestamp;
unsigned long ctx_flags;
#define CTX_FL_OFFLD_START 0
#define CTX_FL_DELETE_WAIT 1
u8 ulp_proto_id;
union {
struct cnic_iscsi *iscsi;
} proto;
};
struct kcq_info {
struct cnic_dma dma;
struct kcqe **kcq;
u16 *hw_prod_idx_ptr;
u16 sw_prod_idx;
u16 *status_idx_ptr;
u32 io_addr;
};
struct iro {
u32 base;
u16 m1;
u16 m2;
u16 m3;
u16 size;
};
struct cnic_uio_dev {
struct uio_info cnic_uinfo;
u32 uio_dev;
int l2_ring_size;
void *l2_ring;
dma_addr_t l2_ring_map;
int l2_buf_size;
void *l2_buf;
dma_addr_t l2_buf_map;
struct cnic_dev *dev;
struct pci_dev *pdev;
struct list_head list;
};
struct cnic_local {
spinlock_t cnic_ulp_lock;
void *ulp_handle[MAX_CNIC_ULP_TYPE];
unsigned long ulp_flags[MAX_CNIC_ULP_TYPE];
#define ULP_F_INIT 0
#define ULP_F_START 1
#define ULP_F_CALL_PENDING 2
struct cnic_ulp_ops __rcu *ulp_ops[MAX_CNIC_ULP_TYPE];
unsigned long cnic_local_flags;
#define CNIC_LCL_FL_KWQ_INIT 0x0
#define CNIC_LCL_FL_L2_WAIT 0x1
#define CNIC_LCL_FL_RINGS_INITED 0x2
#define CNIC_LCL_FL_STOP_ISCSI 0x4
struct cnic_dev *dev;
struct cnic_eth_dev *ethdev;
struct cnic_uio_dev *udev;
int l2_rx_ring_size;
int l2_single_buf_size;
u16 *rx_cons_ptr;
u16 *tx_cons_ptr;
u16 rx_cons;
u16 tx_cons;
struct iro *iro_arr;
#define IRO (((struct cnic_local *) dev->cnic_priv)->iro_arr)
struct cnic_dma kwq_info;
struct kwqe **kwq;
struct cnic_dma kwq_16_data_info;
u16 max_kwq_idx;
u16 kwq_prod_idx;
u32 kwq_io_addr;
u16 *kwq_con_idx_ptr;
u16 kwq_con_idx;
struct kcq_info kcq1;
struct kcq_info kcq2;
union {
void *gen;
struct status_block_msix *bnx2;
struct host_hc_status_block_e1x *bnx2x_e1x;
/* index values - which counter to update */
#define SM_RX_ID 0
#define SM_TX_ID 1
} status_blk;
struct host_sp_status_block *bnx2x_def_status_blk;
u32 status_blk_num;
u32 bnx2x_igu_sb_id;
u32 int_num;
u32 last_status_idx;
struct tasklet_struct cnic_irq_task;
struct kcqe *completed_kcq[MAX_COMPLETED_KCQE];
struct cnic_sock *csk_tbl;
struct cnic_id_tbl csk_port_tbl;
struct cnic_dma conn_buf_info;
struct cnic_dma gbl_buf_info;
struct cnic_iscsi *iscsi_tbl;
struct cnic_context *ctx_tbl;
struct cnic_id_tbl cid_tbl;
atomic_t iscsi_conn;
u32 iscsi_start_cid;
u32 fcoe_init_cid;
u32 fcoe_start_cid;
struct cnic_id_tbl fcoe_cid_tbl;
u32 max_cid_space;
/* per connection parameters */
int num_iscsi_tasks;
int num_ccells;
int task_array_size;
int r2tq_size;
int hq_size;
int num_cqs;
struct delayed_work delete_task;
struct cnic_ctx *ctx_arr;
int ctx_blks;
int ctx_blk_size;
unsigned long ctx_align;
int cids_per_blk;
u32 chip_id;
int func;
u32 pfid;
u32 shmem_base;
struct cnic_ops *cnic_ops;
int (*start_hw)(struct cnic_dev *);
void (*stop_hw)(struct cnic_dev *);
void (*setup_pgtbl)(struct cnic_dev *,
struct cnic_dma *);
int (*alloc_resc)(struct cnic_dev *);
void (*free_resc)(struct cnic_dev *);
int (*start_cm)(struct cnic_dev *);
void (*stop_cm)(struct cnic_dev *);
void (*enable_int)(struct cnic_dev *);
void (*disable_int_sync)(struct cnic_dev *);
void (*ack_int)(struct cnic_dev *);
void (*close_conn)(struct cnic_sock *, u32 opcode);
u16 (*next_idx)(u16);
u16 (*hw_idx)(u16);
};
struct bnx2x_bd_chain_next {
u32 addr_lo;
u32 addr_hi;
u8 reserved[8];
};
#define ISCSI_DEFAULT_MAX_OUTSTANDING_R2T (1)
#define ISCSI_RAMROD_CMD_ID_UPDATE_CONN (ISCSI_KCQE_OPCODE_UPDATE_CONN)
#define ISCSI_RAMROD_CMD_ID_INIT (ISCSI_KCQE_OPCODE_INIT)
#define CDU_REGION_NUMBER_XCM_AG 2
#define CDU_REGION_NUMBER_UCM_AG 4
#define CDU_VALID_DATA(_cid, _region, _type) \
(((_cid) << 8) | (((_region)&0xf)<<4) | (((_type)&0xf)))
#define CDU_CRC8(_cid, _region, _type) \
(calc_crc8(CDU_VALID_DATA(_cid, _region, _type), 0xff))
#define CDU_RSRVD_VALUE_TYPE_A(_cid, _region, _type) \
(0x80 | ((CDU_CRC8(_cid, _region, _type)) & 0x7f))
#define BNX2X_CONTEXT_MEM_SIZE 1024
#define BNX2X_FCOE_CID 16
#define BNX2X_ISCSI_START_CID 18
#define BNX2X_ISCSI_NUM_CONNECTIONS 128
#define BNX2X_ISCSI_TASK_CONTEXT_SIZE 128
#define BNX2X_ISCSI_MAX_PENDING_R2TS 4
#define BNX2X_ISCSI_R2TQE_SIZE 8
#define BNX2X_ISCSI_HQ_BD_SIZE 64
#define BNX2X_ISCSI_CONN_BUF_SIZE 64
#define BNX2X_ISCSI_GLB_BUF_SIZE 64
#define BNX2X_ISCSI_PBL_NOT_CACHED 0xff
#define BNX2X_ISCSI_PDU_HEADER_NOT_CACHED 0xff
#define BNX2X_FCOE_NUM_CONNECTIONS 128
#define BNX2X_FCOE_L5_CID_BASE MAX_ISCSI_TBL_SZ
#define BNX2X_CHIP_NUM_57710 0x164e
#define BNX2X_CHIP_NUM_57711 0x164f
#define BNX2X_CHIP_NUM_57711E 0x1650
#define BNX2X_CHIP_NUM_57712 0x1662
#define BNX2X_CHIP_NUM_57712E 0x1663
#define BNX2X_CHIP_NUM_57713 0x1651
#define BNX2X_CHIP_NUM_57713E 0x1652
#define BNX2X_CHIP_NUM_57800 0x168a
#define BNX2X_CHIP_NUM_57810 0x168e
#define BNX2X_CHIP_NUM_57840 0x168d
#define BNX2X_CHIP_NUM(x) (x >> 16)
#define BNX2X_CHIP_IS_57710(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57710)
#define BNX2X_CHIP_IS_57711(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57711)
#define BNX2X_CHIP_IS_57711E(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57711E)
#define BNX2X_CHIP_IS_E1H(x) \
(BNX2X_CHIP_IS_57711(x) || BNX2X_CHIP_IS_57711E(x))
#define BNX2X_CHIP_IS_57712(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57712)
#define BNX2X_CHIP_IS_57712E(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57712E)
#define BNX2X_CHIP_IS_57713(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57713)
#define BNX2X_CHIP_IS_57713E(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57713E)
#define BNX2X_CHIP_IS_57800(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57800)
#define BNX2X_CHIP_IS_57810(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57810)
#define BNX2X_CHIP_IS_57840(x) \
(BNX2X_CHIP_NUM(x) == BNX2X_CHIP_NUM_57840)
#define BNX2X_CHIP_IS_E2(x) \
(BNX2X_CHIP_IS_57712(x) || BNX2X_CHIP_IS_57712E(x) || \
BNX2X_CHIP_IS_57713(x) || BNX2X_CHIP_IS_57713E(x))
#define BNX2X_CHIP_IS_E3(x) \
(BNX2X_CHIP_IS_57800(x) || BNX2X_CHIP_IS_57810(x) || \
BNX2X_CHIP_IS_57840(x))
#define BNX2X_CHIP_IS_E2_PLUS(x) (BNX2X_CHIP_IS_E2(x) || BNX2X_CHIP_IS_E3(x))
#define IS_E1H_OFFSET BNX2X_CHIP_IS_E1H(cp->chip_id)
#define BNX2X_RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
#define BNX2X_MAX_RX_DESC_CNT (BNX2X_RX_DESC_CNT - 2)
#define BNX2X_RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
#define BNX2X_MAX_RCQ_DESC_CNT (BNX2X_RCQ_DESC_CNT - 1)
#define BNX2X_NEXT_RCQE(x) (((x) & BNX2X_MAX_RCQ_DESC_CNT) == \
(BNX2X_MAX_RCQ_DESC_CNT - 1)) ? \
((x) + 2) : ((x) + 1)
#define BNX2X_DEF_SB_ID HC_SP_SB_ID
#define BNX2X_SHMEM_MF_BLK_OFFSET 0x7e4
#define BNX2X_SHMEM_ADDR(base, field) (base + \
offsetof(struct shmem_region, field))
#define BNX2X_SHMEM2_ADDR(base, field) (base + \
offsetof(struct shmem2_region, field))
#define BNX2X_SHMEM2_HAS(base, field) \
((base) && \
(CNIC_RD(dev, BNX2X_SHMEM2_ADDR(base, size)) > \
offsetof(struct shmem2_region, field)))
#define BNX2X_MF_CFG_ADDR(base, field) \
((base) + offsetof(struct mf_cfg, field))
#ifndef ETH_MAX_RX_CLIENTS_E2
#define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
#endif
#define CNIC_PORT(cp) ((cp)->pfid & 1)
#define CNIC_FUNC(cp) ((cp)->func)
#define CNIC_PATH(cp) (!BNX2X_CHIP_IS_E2(cp->chip_id) ? 0 :\
(CNIC_FUNC(cp) & 1))
#define CNIC_E1HVN(cp) ((cp)->pfid >> 1)
#define BNX2X_HW_CID(cp, x) ((CNIC_PORT(cp) << 23) | \
(CNIC_E1HVN(cp) << 17) | (x))
#define BNX2X_SW_CID(x) (x & 0x1ffff)
#define BNX2X_CL_QZONE_ID(cp, cli) \
(cli + (CNIC_PORT(cp) * (BNX2X_CHIP_IS_E2(cp->chip_id) ?\
ETH_MAX_RX_CLIENTS_E2 : \
ETH_MAX_RX_CLIENTS_E1H)))
#define TCP_TSTORM_OOO_DROP_AND_PROC_ACK (0<<4)
#endif
|
KINGbabasula/u8500_kernel
|
drivers/net/cnic.h
|
C
|
gpl-2.0
| 12,248 |
#ifndef __CUBIC_SPLINE_H__
#define __CUBIC_SPLINE_H__
/*LICENSE_START*/
/*
* Copyright (C) 2014 Washington University School of Medicine
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*LICENSE_END*/
namespace caret {
class CubicSpline
{
float m_weights[4];
CubicSpline();
public:
///takes as input the fraction in [0, 1] along the middle (used) range of the spline, low and high edge set whether it doesn't have p[0] or p[3] to use, respectively
static CubicSpline hermite(float frac, bool lowEdge, bool highEdge);
///NOTE: data should be deconvolved before using this spline
static CubicSpline bspline(float frac, bool lowEdge, bool highEdge);
//splines will be reused, so this part should be fast for the majority case (testing for if it is an edge case would slow it down for the majority case)
///evaluate the spline with these samples
inline float evaluate(const float p0, const float p1, const float p2, const float p3) const
{
return p0 * m_weights[0] + p1 * m_weights[1] + p2 * m_weights[2] + p3 * m_weights[3];
}
///convenience function for edge evaluating without a dummy argument
inline float evalLowEdge(const float p1, const float p2, const float p3)
{
return p1 * m_weights[1] + p2 * m_weights[2] + p3 * m_weights[3];
}
///convenience function for edge evaluating without a dummy argument
inline float evalHighEdge(const float p0, const float p1, const float p2)
{
return p0 * m_weights[0] + p1 * m_weights[1] + p2 * m_weights[2];
}
///convenience function for edge evaluating without dummy arguments
inline float evalBothEdge(const float p1, const float p2)
{
return p1 * m_weights[1] + p2 * m_weights[2];
}
};
}
#endif //__CUBIC_SPLINE_H__
|
Washington-University/workbench
|
src/Common/CubicSpline.h
|
C
|
gpl-2.0
| 2,638 |
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893
local NEUTRAL_MATTER = 8310
local THE_MUTATED_PUMPKIN = 8961
local PUMPKINHEAD = 2097
local PUMPKIN = 2683
local CANDY_CANE = 2688
local SUPRISE_BAG = 6570
local BAT_DECORATION = 6492
local SKELETON_DECORATION = 6526
local BAR_OF_CHOCOLATE = 6574
local YUMMY_GUMMY_WORM = 9005
local ICE_CUBE = {7441, 7442, 7444, 7445, 7446, last = 7446}
local knife = {
-- Minotaur Archer
[2871] = MINOTAUR_LEATHER,
-- Minotaur Guard
[2876] = MINOTAUR_LEATHER,
-- Minotaur Mage
[2866] = MINOTAUR_LEATHER,
-- Minotaur
[3090] = MINOTAUR_LEATHER,
-- Dragon Lord
[2881] = RED_DRAGON_LEATHER,
-- Dragon
[3104] = GREEN_DRAGON_LEATHER,
-- Behemoth
[2931] = BEHEMOTH_FANG,
-- Lizard Sentinel
[4259] = LIZARD_LEATHER,
-- Lizard Snakecharmer
[4262] = LIZARD_LEATHER,
-- Lizard Templar
[4260] = LIZARD_LEATHER,
-- Wivern
[6303] = LIZARD_LEATHER,
-- Bone Beast
[3031] = HARDENED_BONE,
-- Lord of The Elements
[9009] = NEUTRAL_MATTER,
-- The Mutated Pumpkin
[THE_MUTATED_PUMPKIN] = {PUMPKINHEAD, PUMPKIN, CANDY_CANE, SUPRISE_BAG, BAT_DECORATION, SKELETON_DECORATION, BAR_OF_CHOCOLATE, YUMMY_GUMMY_WORM}
}
function onUse(cid, item, frompos, item2, topos)
if isInArray(ICE_CUBE, item2.itemid) and ICE_CUBE.last ~= item2.itemid then
local random = math.random(1, 10)
doSendMagicEffect(getThingPos(item2.uid), CONST_ME_BLOCKHIT)
if random >= 5 then
doTransformItem(item2.uid, ICE_CUBE[table.find(ICE_CUBE, item2.itemid) + 1])
if item2.actionid ~= 0 then
doSetItemActionId(item2.uid, item2.actionid)
end
else
doRemoveItem(item2.uid)
end
return true
end
-- Statues --
if (item2.itemid == 11343) then
local random2 = math.random(1, 20)
if (random2 <= 2) == true then
doTransformItem(item2.uid, 11346)
doSendMagicEffect(getThingPos(item2.uid), CONST_ME_BLOCKHIT)
doSetItemSpecialDescription(item2.uid, "This little figurine of Tibiasula was masterfully sculpted by " .. getCreatureName(cid) .. ".")
return true
end
if (random2 >= 3) == true and not (random2 > 5) then
doTransformItem(item2.uid, 11345)
doSendMagicEffect(getThingPos(item2.uid), CONST_ME_BLOCKHIT)
doSetItemSpecialDescription(item2.uid, "This little figurine made by " ..getCreatureName(cid).. " has some room for improvement.")
return true
end
if (random2 >= 6) == true and not (random2 > 13) then
doTransformItem(item2.uid, 11344)
doSendMagicEffect(getThingPos(item2.uid), CONST_ME_BLOCKHIT)
doSetItemSpecialDescription(item2.uid, "This shoddy work was made by " ..getCreatureName(cid).. ".")
return true
end
if (random2 >= 14) == true and not (random2 > 20) then
doSendMagicEffect(getThingPos(item2.uid), CONST_ME_BLOCKHIT)
doRemoveItem(item2.uid)
return true
end
return false
end
-- End --
if (knife[item2.itemid] == nil) then
return false
end
if (math.random(1, 15) == 1) then
if (item2.itemid == THE_MUTATED_PUMPKIN) then
doPlayerAddItem(cid, knife[THE_MUTATED_PUMPKIN][math.random(1, 8)], 1)
else
doPlayerAddItem(cid, knife[item2.itemid], 1)
end
doSendMagicEffect(getThingPos(item2.uid), CONST_ME_MAGIC_GREEN)
else
doSendMagicEffect(getThingPos(item2.uid), CONST_ME_BLOCKHIT)
end
doTransformItem(item2.uid, item2.itemid + 1)
doDecayItem(item2.uid)
if item2.actionid ~= 0 then
doSetItemActionId(item2.uid, item2.actionid)
end
return true
end
|
Nottinghster/OTServ_SVN-0.6.4
|
src/data/actions/scripts/obsidian_knife.lua
|
Lua
|
gpl-2.0
| 3,741 |
<?php
/**
* Nooku Framework - http://nooku.org/framework
*
* @copyright Copyright (C) 2007 - 2014 Johan Janssens and Timble CVBA. (http://www.timble.net)
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link https://github.com/nooku/nooku-framework for the canonical source repository
*/
/**
* Template Locator Interface
*
* @author Johan Janssens <https://github.com/johanjanssens>
* @package Koowa\Library\Template\Locator
*/
interface KTemplateLocatorInterface
{
/**
* Get the locator name
*
* @return string The stream name
*/
public static function getName();
/**
* Sets the base path
*
* @param string $path The path (used to resolved partials).
* @return KTemplateLocatorInterface
*/
public function setBasePath($path);
/**
* Get the path
*
* @return string|null
*/
public function getBasePath();
/**
* Find the template path
*
* @param string $url The Template url
* @throws RuntimeException If the no base path exists while trying to locate a partial.
* @return string|false The real template path or FALSE if the template could not be found
*/
public function locate($url);
/**
* Find a template path
*
* @param array $info The path information
* @return string|false The real template path or FALSE if the template could not be found
*/
public function find(array $info);
/**
* Get a path from an file
*
* Function will check if the path is an alias and return the real file path
*
* @param string $file The file path
* @return string The real file path
*/
public function realPath($file);
/**
* Returns true if the template is still fresh.
*
* @param string $url The Template url
* @param int $time The last modification time of the cached template (timestamp)
* @return bool TRUE if the template is still fresh, FALSE otherwise
*/
public function isFresh($url, $time);
}
|
kosmosby/medicine-prof
|
libraries/koowa/libraries/template/locator/interface.php
|
PHP
|
gpl-2.0
| 2,084 |
#
# Makefile for MMC/SD host controller drivers
#
obj-$(CONFIG_MMC0_JZ4780) += jz4780_mmc.o
obj-$(CONFIG_MMC1_JZ4780) += jz4780_mmc.o
obj-$(CONFIG_MMC2_JZ4780) += jz4780_mmc.o
obj-$(CONFIG_MMC0_JZ4775) += jz4775_mmc.o
obj-$(CONFIG_MMC1_JZ4775) += jz4775_mmc.o
obj-$(CONFIG_MMC2_JZ4775) += jz4775_mmc.o
obj-$(CONFIG_MMC_ARMMMCI) += mmci.o
obj-$(CONFIG_MMC_PXA) += pxamci.o
obj-$(CONFIG_MMC_IMX) += imxmmc.o
obj-$(CONFIG_MMC_MXC) += mxcmmc.o
obj-$(CONFIG_MMC_MXS) += mxs-mmc.o
obj-$(CONFIG_MMC_SDHCI) += sdhci.o
obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o
obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += sdhci-pci-data.o
obj-$(CONFIG_MMC_SDHCI_PXAV3) += sdhci-pxav3.o
obj-$(CONFIG_MMC_SDHCI_PXAV2) += sdhci-pxav2.o
obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o
obj-$(CONFIG_MMC_SDHCI_SPEAR) += sdhci-spear.o
obj-$(CONFIG_MMC_WBSD) += wbsd.o
obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
obj-$(CONFIG_MMC_OMAP) += omap.o
obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o
obj-$(CONFIG_MMC_AT91) += at91_mci.o
obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o
obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
obj-$(CONFIG_MMC_MSM) += msm_sdcc.o
obj-$(CONFIG_MMC_MVSDIO) += mvsdio.o
obj-$(CONFIG_MMC_DAVINCI) += davinci_mmc.o
obj-$(CONFIG_MMC_SPI) += mmc_spi.o
ifeq ($(CONFIG_OF),y)
obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o
endif
obj-$(CONFIG_MMC_S3C) += s3cmci.o
obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o
obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o
obj-$(CONFIG_MMC_TMIO_CORE) += tmio_mmc_core.o
tmio_mmc_core-y := tmio_mmc_pio.o
tmio_mmc_core-$(subst m,y,$(CONFIG_MMC_SDHI)) += tmio_mmc_dma.o
obj-$(CONFIG_MMC_SDHI) += sh_mobile_sdhi.o
obj-$(CONFIG_MMC_CB710) += cb710-mmc.o
obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o
obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o
obj-$(CONFIG_MMC_DW) += dw_mmc.o
obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o
obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o
obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o
obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o
obj-$(CONFIG_MMC_VUB300) += vub300.o
obj-$(CONFIG_MMC_USHC) += ushc.o
obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o
obj-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o
obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.o
obj-$(CONFIG_MMC_SDHCI_DOVE) += sdhci-dove.o
obj-$(CONFIG_MMC_SDHCI_TEGRA) += sdhci-tegra.o
obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o
obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o
ifeq ($(CONFIG_CB710_DEBUG),y)
CFLAGS-cb710-mmc += -DDEBUG
endif
|
IngenicSemiconductor/KERNEL-NPM801
|
drivers/mmc/host/Makefile
|
Makefile
|
gpl-2.0
| 2,423 |
/*
** Copyright 2003-2010, VisualOn, 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.
*/
/*******************************************************************************
File: adj_thr_data.h
Content: Threshold compensation parameter
*******************************************************************************/
#ifndef __ADJ_THR_DATA_H
#define __ADJ_THR_DATA_H
#include "typedef.h"
#include "psy_const.h"
#include "line_pe.h"
typedef struct {
Word16 clipSaveLow, clipSaveHigh;
Word16 minBitSave, maxBitSave;
Word16 clipSpendLow, clipSpendHigh;
Word16 minBitSpend, maxBitSpend;
} BRES_PARAM;
typedef struct {
UWord8 modifyMinSnr;
Word16 startSfbL, startSfbS;
} AH_PARAM;
typedef struct {
Word32 maxRed;
Word32 startRatio, maxRatio;
Word32 redRatioFac;
Word32 redOffs;
} MINSNR_ADAPT_PARAM;
typedef struct {
/* parameters for bitreservoir control */
Word16 peMin, peMax;
/* constant offset to pe */
Word16 peOffset;
/* avoid hole parameters */
AH_PARAM ahParam;
/* paramters for adaptation of minSnr */
MINSNR_ADAPT_PARAM minSnrAdaptParam;
/* values for correction of pe */
Word16 peLast;
Word16 dynBitsLast;
Word16 peCorrectionFactor;
} ATS_ELEMENT;
typedef struct {
BRES_PARAM bresParamLong, bresParamShort; /* Word16 size: 2*8 */
ATS_ELEMENT adjThrStateElem; /* Word16 size: 19 */
} ADJ_THR_STATE;
#endif
|
luquanhong/MyCodec
|
projects/stagefright/jni/src/codec/decoder/video/sw_opencore/OEM/jni/media/frameworks/base/media/libstagefright/codecs/aacenc/inc/adj_thr_data.h
|
C
|
gpl-2.0
| 1,951 |
/*
* Copyright (C) 2011, 2013-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE 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, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "DFGOSRExitCompiler.h"
#if ENABLE(DFG_JIT) && USE(JSVALUE32_64)
#include "DFGOperations.h"
#include "DFGOSRExitCompilerCommon.h"
#include "DFGSpeculativeJIT.h"
#include "JSCInlines.h"
#include <wtf/DataLog.h>
namespace JSC { namespace DFG {
void OSRExitCompiler::compileExit(const OSRExit& exit, const Operands<ValueRecovery>& operands, SpeculationRecovery* recovery)
{
// Pro-forma stuff.
if (Options::printEachOSRExit()) {
SpeculationFailureDebugInfo* debugInfo = new SpeculationFailureDebugInfo;
debugInfo->codeBlock = m_jit.codeBlock();
debugInfo->kind = exit.m_kind;
debugInfo->bytecodeOffset = exit.m_codeOrigin.bytecodeIndex;
m_jit.debugCall(debugOperationPrintSpeculationFailure, debugInfo);
}
// Perform speculation recovery. This only comes into play when an operation
// starts mutating state before verifying the speculation it has already made.
if (recovery) {
switch (recovery->type()) {
case SpeculativeAdd:
m_jit.sub32(recovery->src(), recovery->dest());
break;
case BooleanSpeculationCheck:
break;
default:
break;
}
}
// Refine some value profile, if appropriate.
if (!!exit.m_jsValueSource) {
if (exit.m_kind == BadCache || exit.m_kind == BadIndexingType) {
// If the instruction that this originated from has an array profile, then
// refine it. If it doesn't, then do nothing. The latter could happen for
// hoisted checks, or checks emitted for operations that didn't have array
// profiling - either ops that aren't array accesses at all, or weren't
// known to be array acceses in the bytecode. The latter case is a FIXME
// while the former case is an outcome of a CheckStructure not knowing why
// it was emitted (could be either due to an inline cache of a property
// property access, or due to an array profile).
// Note: We are free to assume that the jsValueSource is already known to
// be a cell since both BadCache and BadIndexingType exits occur after
// the cell check would have already happened.
CodeOrigin codeOrigin = exit.m_codeOriginForExitProfile;
if (ArrayProfile* arrayProfile = m_jit.baselineCodeBlockFor(codeOrigin)->getArrayProfile(codeOrigin.bytecodeIndex)) {
GPRReg usedRegister1;
GPRReg usedRegister2;
if (exit.m_jsValueSource.isAddress()) {
usedRegister1 = exit.m_jsValueSource.base();
usedRegister2 = InvalidGPRReg;
} else {
usedRegister1 = exit.m_jsValueSource.payloadGPR();
if (exit.m_jsValueSource.hasKnownTag())
usedRegister2 = InvalidGPRReg;
else
usedRegister2 = exit.m_jsValueSource.tagGPR();
}
GPRReg scratch1;
GPRReg scratch2;
scratch1 = AssemblyHelpers::selectScratchGPR(usedRegister1, usedRegister2);
scratch2 = AssemblyHelpers::selectScratchGPR(usedRegister1, usedRegister2, scratch1);
m_jit.push(scratch1);
m_jit.push(scratch2);
GPRReg value;
if (exit.m_jsValueSource.isAddress()) {
value = scratch1;
m_jit.loadPtr(AssemblyHelpers::Address(exit.m_jsValueSource.asAddress()), value);
} else
value = exit.m_jsValueSource.payloadGPR();
m_jit.loadPtr(AssemblyHelpers::Address(value, JSCell::structureIDOffset()), scratch1);
m_jit.storePtr(scratch1, arrayProfile->addressOfLastSeenStructureID());
m_jit.load8(AssemblyHelpers::Address(scratch1, Structure::indexingTypeOffset()), scratch1);
m_jit.move(AssemblyHelpers::TrustedImm32(1), scratch2);
m_jit.lshift32(scratch1, scratch2);
m_jit.or32(scratch2, AssemblyHelpers::AbsoluteAddress(arrayProfile->addressOfArrayModes()));
m_jit.pop(scratch2);
m_jit.pop(scratch1);
}
}
if (!!exit.m_valueProfile) {
EncodedJSValue* bucket = exit.m_valueProfile.getSpecFailBucket(0);
if (exit.m_jsValueSource.isAddress()) {
// Save a register so we can use it.
GPRReg scratch = AssemblyHelpers::selectScratchGPR(exit.m_jsValueSource.base());
m_jit.push(scratch);
m_jit.load32(exit.m_jsValueSource.asAddress(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)), scratch);
m_jit.store32(scratch, &bitwise_cast<EncodedValueDescriptor*>(bucket)->asBits.tag);
m_jit.load32(exit.m_jsValueSource.asAddress(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)), scratch);
m_jit.store32(scratch, &bitwise_cast<EncodedValueDescriptor*>(bucket)->asBits.payload);
m_jit.pop(scratch);
} else if (exit.m_jsValueSource.hasKnownTag()) {
m_jit.store32(AssemblyHelpers::TrustedImm32(exit.m_jsValueSource.tag()), &bitwise_cast<EncodedValueDescriptor*>(bucket)->asBits.tag);
m_jit.store32(exit.m_jsValueSource.payloadGPR(), &bitwise_cast<EncodedValueDescriptor*>(bucket)->asBits.payload);
} else {
m_jit.store32(exit.m_jsValueSource.tagGPR(), &bitwise_cast<EncodedValueDescriptor*>(bucket)->asBits.tag);
m_jit.store32(exit.m_jsValueSource.payloadGPR(), &bitwise_cast<EncodedValueDescriptor*>(bucket)->asBits.payload);
}
}
}
// Do a simplified OSR exit. See DFGOSRExitCompiler64.cpp's comment regarding how and wny we
// do this simple approach.
// Save all state from GPRs into the scratch buffer.
ScratchBuffer* scratchBuffer = m_jit.vm()->scratchBufferForSize(sizeof(EncodedJSValue) * operands.size());
EncodedJSValue* scratch = scratchBuffer ? static_cast<EncodedJSValue*>(scratchBuffer->dataBuffer()) : 0;
for (size_t index = 0; index < operands.size(); ++index) {
const ValueRecovery& recovery = operands[index];
switch (recovery.technique()) {
case UnboxedInt32InGPR:
case UnboxedBooleanInGPR:
case UnboxedCellInGPR:
m_jit.store32(
recovery.gpr(),
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload);
break;
case InPair:
m_jit.store32(
recovery.tagGPR(),
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.tag);
m_jit.store32(
recovery.payloadGPR(),
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload);
break;
default:
break;
}
}
// Now all GPRs are free to reuse.
// Save all state from FPRs into the scratch buffer.
for (size_t index = 0; index < operands.size(); ++index) {
const ValueRecovery& recovery = operands[index];
switch (recovery.technique()) {
case UnboxedDoubleInFPR:
case InFPR:
m_jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
m_jit.storeDouble(recovery.fpr(), MacroAssembler::Address(GPRInfo::regT0));
break;
default:
break;
}
}
// Now all FPRs are free to reuse.
// Save all state from the stack into the scratch buffer. For simplicity we
// do this even for state that's already in the right place on the stack.
// It makes things simpler later.
for (size_t index = 0; index < operands.size(); ++index) {
const ValueRecovery& recovery = operands[index];
switch (recovery.technique()) {
case DisplacedInJSStack:
case Int32DisplacedInJSStack:
case DoubleDisplacedInJSStack:
case CellDisplacedInJSStack:
case BooleanDisplacedInJSStack:
m_jit.load32(
AssemblyHelpers::tagFor(recovery.virtualRegister()),
GPRInfo::regT0);
m_jit.load32(
AssemblyHelpers::payloadFor(recovery.virtualRegister()),
GPRInfo::regT1);
m_jit.store32(
GPRInfo::regT0,
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.tag);
m_jit.store32(
GPRInfo::regT1,
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload);
break;
default:
break;
}
}
// Need to ensure that the stack pointer accounts for the worst-case stack usage at exit. This
// could toast some stack that the DFG used. We need to do it before storing to stack offsets
// used by baseline.
m_jit.addPtr(
CCallHelpers::TrustedImm32(
-m_jit.codeBlock()->jitCode()->dfgCommon()->requiredRegisterCountForExit * sizeof(Register)),
CCallHelpers::framePointerRegister, CCallHelpers::stackPointerRegister);
// Restore the DFG callee saves and then save the ones the baseline JIT uses.
m_jit.emitRestoreCalleeSaves();
m_jit.emitSaveCalleeSavesFor(m_jit.baselineCodeBlock());
if (exit.isExceptionHandler())
m_jit.copyCalleeSavesToVMCalleeSavesBuffer();
// Do all data format conversions and store the results into the stack.
for (size_t index = 0; index < operands.size(); ++index) {
const ValueRecovery& recovery = operands[index];
VirtualRegister reg = operands.virtualRegisterForIndex(index);
if (reg.isLocal() && reg.toLocal() < static_cast<int>(m_jit.baselineCodeBlock()->calleeSaveSpaceAsVirtualRegisters()))
continue;
int operand = reg.offset();
switch (recovery.technique()) {
case InPair:
case DisplacedInJSStack:
case InFPR:
m_jit.load32(
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.tag,
GPRInfo::regT0);
m_jit.load32(
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
GPRInfo::regT1);
m_jit.store32(
GPRInfo::regT0,
AssemblyHelpers::tagFor(operand));
m_jit.store32(
GPRInfo::regT1,
AssemblyHelpers::payloadFor(operand));
break;
case UnboxedDoubleInFPR:
case DoubleDisplacedInJSStack:
m_jit.move(AssemblyHelpers::TrustedImmPtr(scratch + index), GPRInfo::regT0);
m_jit.loadDouble(MacroAssembler::Address(GPRInfo::regT0), FPRInfo::fpRegT0);
m_jit.purifyNaN(FPRInfo::fpRegT0);
m_jit.storeDouble(FPRInfo::fpRegT0, AssemblyHelpers::addressFor(operand));
break;
case UnboxedInt32InGPR:
case Int32DisplacedInJSStack:
m_jit.load32(
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
GPRInfo::regT0);
m_jit.store32(
AssemblyHelpers::TrustedImm32(JSValue::Int32Tag),
AssemblyHelpers::tagFor(operand));
m_jit.store32(
GPRInfo::regT0,
AssemblyHelpers::payloadFor(operand));
break;
case UnboxedCellInGPR:
case CellDisplacedInJSStack:
m_jit.load32(
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
GPRInfo::regT0);
m_jit.store32(
AssemblyHelpers::TrustedImm32(JSValue::CellTag),
AssemblyHelpers::tagFor(operand));
m_jit.store32(
GPRInfo::regT0,
AssemblyHelpers::payloadFor(operand));
break;
case UnboxedBooleanInGPR:
case BooleanDisplacedInJSStack:
m_jit.load32(
&bitwise_cast<EncodedValueDescriptor*>(scratch + index)->asBits.payload,
GPRInfo::regT0);
m_jit.store32(
AssemblyHelpers::TrustedImm32(JSValue::BooleanTag),
AssemblyHelpers::tagFor(operand));
m_jit.store32(
GPRInfo::regT0,
AssemblyHelpers::payloadFor(operand));
break;
case Constant:
m_jit.store32(
AssemblyHelpers::TrustedImm32(recovery.constant().tag()),
AssemblyHelpers::tagFor(operand));
m_jit.store32(
AssemblyHelpers::TrustedImm32(recovery.constant().payload()),
AssemblyHelpers::payloadFor(operand));
break;
case DirectArgumentsThatWereNotCreated:
case ClonedArgumentsThatWereNotCreated:
// Don't do this, yet.
break;
default:
break;
}
}
// Now that things on the stack are recovered, do the arguments recovery. We assume that arguments
// recoveries don't recursively refer to each other. But, we don't try to assume that they only
// refer to certain ranges of locals. Hence why we need to do this here, once the stack is sensible.
// Note that we also roughly assume that the arguments might still be materialized outside of its
// inline call frame scope - but for now the DFG wouldn't do that.
emitRestoreArguments(operands);
// Adjust the old JIT's execute counter. Since we are exiting OSR, we know
// that all new calls into this code will go to the new JIT, so the execute
// counter only affects call frames that performed OSR exit and call frames
// that were still executing the old JIT at the time of another call frame's
// OSR exit. We want to ensure that the following is true:
//
// (a) Code the performs an OSR exit gets a chance to reenter optimized
// code eventually, since optimized code is faster. But we don't
// want to do such reentery too aggressively (see (c) below).
//
// (b) If there is code on the call stack that is still running the old
// JIT's code and has never OSR'd, then it should get a chance to
// perform OSR entry despite the fact that we've exited.
//
// (c) Code the performs an OSR exit should not immediately retry OSR
// entry, since both forms of OSR are expensive. OSR entry is
// particularly expensive.
//
// (d) Frequent OSR failures, even those that do not result in the code
// running in a hot loop, result in recompilation getting triggered.
//
// To ensure (c), we'd like to set the execute counter to
// counterValueForOptimizeAfterWarmUp(). This seems like it would endanger
// (a) and (b), since then every OSR exit would delay the opportunity for
// every call frame to perform OSR entry. Essentially, if OSR exit happens
// frequently and the function has few loops, then the counter will never
// become non-negative and OSR entry will never be triggered. OSR entry
// will only happen if a loop gets hot in the old JIT, which does a pretty
// good job of ensuring (a) and (b). But that doesn't take care of (d),
// since each speculation failure would reset the execute counter.
// So we check here if the number of speculation failures is significantly
// larger than the number of successes (we want 90% success rate), and if
// there have been a large enough number of failures. If so, we set the
// counter to 0; otherwise we set the counter to
// counterValueForOptimizeAfterWarmUp().
handleExitCounts(m_jit, exit);
// Reify inlined call frames.
reifyInlinedCallFrames(m_jit, exit);
// And finish.
adjustAndJumpToTarget(m_jit, exit);
}
} } // namespace JSC::DFG
#endif // ENABLE(DFG_JIT) && USE(JSVALUE32_64)
|
qtproject/qtwebkit
|
Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp
|
C++
|
gpl-2.0
| 17,851 |
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
#
# 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, see <http://www.gnu.org/licenses/>.
package Sympa::Spindle::DoMessage;
use strict;
use warnings;
use Sympa;
use Conf;
use Sympa::Language;
use Sympa::Log;
use Sympa::Regexps;
use base qw(Sympa::Spindle::ProcessIncoming); # Deriving _splicing_to().
my $log = Sympa::Log->instance;
# Old name: (part of) DoMessage() in sympa_msg.pl.
sub _twist {
my $self = shift;
my $message = shift;
# Fail-safe: Skip messages with unwanted types.
return 0 unless $self->_splicing_to($message) eq __PACKAGE__;
# List unknown.
unless (ref $message->{context} eq 'Sympa::List') {
$log->syslog('notice', 'Unknown list %s', $message->{localpart});
Sympa::send_dsn($message->{context} || '*', $message, {}, '5.1.1');
return undef;
}
my $list = $message->{context};
Sympa::Language->instance->set_lang(
$list->{'admin'}{'lang'},
Conf::get_robot_conf($list->{'domain'}, 'lang'),
$Conf::Conf{'lang'}, 'en'
);
my $messageid = $message->{message_id};
my $sender = $message->{sender};
$log->syslog('info',
'Processing message %s for %s with priority %s, <%s>',
$message, $list, $list->{'admin'}{'priority'}, $messageid);
if ($self->{_msgid}{$list->get_id}{$messageid}) {
$log->syslog(
'err',
'Found known Message-ID <%s>, ignoring message %s which would cause a loop',
$messageid,
$message
);
$log->db_log(
'robot' => $list->{'domain'},
'list' => $list->{'name'},
'action' => 'DoMessage',
'parameters' => $message->get_id,
'target_email' => '',
'msg_id' => $messageid,
'status' => 'error',
'error_type' => 'known_message',
'user_email' => $sender
);
return undef;
}
# Reject messages with commands
if ($Conf::Conf{'misaddressed_commands'} =~ /reject/i) {
# Check the message for commands and catch them.
my $cmd = _check_command($message);
if (defined $cmd) {
$log->syslog('err',
'Found command "%s" in message, ignoring message', $cmd);
Sympa::send_dsn($list, $message, {cmd => $cmd}, '5.6.0');
$log->db_log(
'robot' => $list->{'domain'},
'list' => $list->{'name'},
'action' => 'DoMessage',
'parameters' => $message->get_id,
'target_email' => '',
'msg_id' => $messageid,
'status' => 'error',
'error_type' => 'routing_error',
'user_email' => $sender
);
return undef;
}
}
# Check if the message is too large
my $max_size = $list->{'admin'}{'max_size'};
if ($max_size and $max_size < $message->{size}) {
$log->syslog('info',
'Message for %s from %s rejected because too large (%d > %d)',
$list, $sender, $message->{size}, $max_size);
Sympa::send_dsn($list, $message, {}, '5.2.3');
$log->db_log(
'robot' => $list->{'domain'},
'list' => $list->{'name'},
'action' => 'DoMessage',
'parameters' => $message->get_id,
'target_email' => '',
'msg_id' => $messageid,
'status' => 'error',
'error_type' => 'message_too_large',
'user_email' => $sender
);
return undef;
}
return ['Sympa::Spindle::AuthorizeMessage'];
}
# Checks command in subject or body of the message.
# If there are any commands in it, returns string. Otherwise returns undef.
#
# Old name: tools::checkcommand(), _check_command() in sympa_msg.pl.
sub _check_command {
my $message = shift;
my $commands_re = $Conf::Conf{'misaddressed_commands_regexp'};
return undef unless defined $commands_re and length $commands_re;
# Check for commands in the subject.
my $subject_field = $message->{'decoded_subject'};
$subject_field = '' unless defined $subject_field;
$subject_field =~ s/\n//mg; # multiline subjects
my $re_regexp = Sympa::Regexps::re();
$subject_field =~ s/^\s*(?:$re_regexp)?\s*(.*)\s*$/$1/i;
if ($subject_field =~ /^($commands_re)$/im) {
return $1;
}
my @body = map { s/\r\n|\n//; $_ } split /(?<=\n)/,
($message->get_plain_body || '');
# More than 5 lines in the text.
return undef if scalar @body > 5;
foreach my $line (@body) {
if ($line =~ /^($commands_re)\b/im) {
return $1;
}
# Control is only applied to first non-blank line.
last unless $line =~ /\A\s*\z/;
}
return undef;
}
1;
__END__
=encoding utf-8
=head1 NAME
Sympa::Spindle::DoMessage - Workflow to handle messages bound for lists
=head1 DESCRIPTION
L<Sympa::Spindle::DoMessage> handles a message sent to a list.
If a message has no special types (command or administrator),
message will be processed. Otherwise messages will be skipped.
TBD
=head2 Public methods
See also L<Sympa::Spindle::ProcessIncoming/"Public methods">.
=over
=item new ( key =E<gt> value, ... )
=item spin ( )
In most cases, L<Sympa::Spindle::ProcessIncoming> splices messages
to this class. These methods are not used in ordinal case.
=back
=head1 SEE ALSO
L<Sympa::Message>, L<Sympa::Spindle::AuthorizeMessage>,
L<Sympa::Spindle::ProcessIncoming>.
=head1 HISTORY
L<Sympa::Spindle::DoMessage> appeared on Sympa 6.2.13.
=cut
|
eiro/sympa
|
src/lib/Sympa/Spindle/DoMessage.pm
|
Perl
|
gpl-2.0
| 6,668 |
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2017-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://oss.oracle.com/licenses/CDDL+GPL-1.1
* or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package javax.servlet;
import java.util.*;
/**
* Interface through which a {@link Servlet} may be further configured.
*
* @since Servlet 3.0
*/
public interface ServletRegistration extends Registration {
/**
* Adds a servlet mapping with the given URL patterns for the Servlet
* represented by this ServletRegistration.
*
* <p>If any of the specified URL patterns are already mapped to a
* different Servlet, no updates will be performed.
*
* <p>If this method is called multiple times, each successive call
* adds to the effects of the former.
*
* <p>The returned set is not backed by the {@code ServletRegistration}
* object, so changes in the returned set are not reflected in the
* {@code ServletRegistration} object, and vice-versa.</p>
*
* @param urlPatterns the URL patterns of the servlet mapping
*
* @return the (possibly empty) Set of URL patterns that are already
* mapped to a different Servlet
*
* @throws IllegalArgumentException if <tt>urlPatterns</tt> is null
* or empty
* @throws IllegalStateException if the ServletContext from which this
* ServletRegistration was obtained has already been initialized
*/
public Set<String> addMapping(String... urlPatterns);
/**
* Gets the currently available mappings of the
* Servlet represented by this <code>ServletRegistration</code>.
*
* <p>If permitted, any changes to the returned <code>Collection</code> must not
* affect this <code>ServletRegistration</code>.
*
* @return a (possibly empty) <code>Collection</code> of the currently
* available mappings of the Servlet represented by this
* <code>ServletRegistration</code>
*/
public Collection<String> getMappings();
/**
* Gets the name of the runAs role of the Servlet represented by this
* <code>ServletRegistration</code>.
*
* @return the name of the runAs role, or null if the Servlet is
* configured to run as its caller
*/
public String getRunAsRole();
/**
* Interface through which a {@link Servlet} registered via one of the
* <tt>addServlet</tt> methods on {@link ServletContext} may be further
* configured.
*/
interface Dynamic extends ServletRegistration, Registration.Dynamic {
/**
* Sets the <code>loadOnStartup</code> priority on the Servlet
* represented by this dynamic ServletRegistration.
*
* <p>A <tt>loadOnStartup</tt> value of greater than or equal to
* zero indicates to the container the initialization priority of
* the Servlet. In this case, the container must instantiate and
* initialize the Servlet during the initialization phase of the
* ServletContext, that is, after it has invoked all of the
* ServletContextListener objects configured for the ServletContext
* at their {@link ServletContextListener#contextInitialized}
* method.
*
* <p>If <tt>loadOnStartup</tt> is a negative integer, the container
* is free to instantiate and initialize the Servlet lazily.
*
* <p>The default value for <tt>loadOnStartup</tt> is <code>-1</code>.
*
* <p>A call to this method overrides any previous setting.
*
* @param loadOnStartup the initialization priority of the Servlet
*
* @throws IllegalStateException if the ServletContext from which
* this ServletRegistration was obtained has already been initialized
*/
public void setLoadOnStartup(int loadOnStartup);
/**
* Sets the {@link ServletSecurityElement} to be applied to the
* mappings defined for this <code>ServletRegistration</code>.
*
* <p>This method applies to all mappings added to this
* <code>ServletRegistration</code> up until the point that the
* <code>ServletContext</code> from which it was obtained has been
* initialized.
*
* <p>If a URL pattern of this ServletRegistration is an exact target
* of a <code>security-constraint</code> that was established via
* the portable deployment descriptor, then this method does not
* change the <code>security-constraint</code> for that pattern,
* and the pattern will be included in the return value.
*
* <p>If a URL pattern of this ServletRegistration is an exact
* target of a security constraint that was established via the
* {@link javax.servlet.annotation.ServletSecurity} annotation
* or a previous call to this method, then this method replaces
* the security constraint for that pattern.
*
* <p>If a URL pattern of this ServletRegistration is neither the
* exact target of a security constraint that was established via
* the {@link javax.servlet.annotation.ServletSecurity} annotation
* or a previous call to this method, nor the exact target of a
* <code>security-constraint</code> in the portable deployment
* descriptor, then this method establishes the security constraint
* for that pattern from the argument
* <code>ServletSecurityElement</code>.
*
* <p>The returned set is not backed by the {@code Dynamic} object,
* so changes in the returned set are not reflected in the
* {@code Dynamic} object, and vice-versa.</p>
*
* @param constraint the {@link ServletSecurityElement} to be applied
* to the patterns mapped to this ServletRegistration
*
* @return the (possibly empty) Set of URL patterns that were already
* the exact target of a <code>security-constraint</code> that was
* established via the portable deployment descriptor. This method
* has no effect on the patterns included in the returned set
*
* @throws IllegalArgumentException if <tt>constraint</tt> is null
*
* @throws IllegalStateException if the {@link ServletContext} from
* which this <code>ServletRegistration</code> was obtained has
* already been initialized
*/
public Set<String> setServletSecurity(ServletSecurityElement constraint);
/**
* Sets the {@link MultipartConfigElement} to be applied to the
* mappings defined for this <code>ServletRegistration</code>. If this
* method is called multiple times, each successive call overrides the
* effects of the former.
*
* @param multipartConfig the {@link MultipartConfigElement} to be
* applied to the patterns mapped to the registration
*
* @throws IllegalArgumentException if <tt>multipartConfig</tt> is
* null
*
* @throws IllegalStateException if the {@link ServletContext} from
* which this ServletRegistration was obtained has already been
* initialized
*/
public void setMultipartConfig(
MultipartConfigElement multipartConfig);
/**
* Sets the name of the <code>runAs</code> role for this
* <code>ServletRegistration</code>.
*
* @param roleName the name of the <code>runAs</code> role
*
* @throws IllegalArgumentException if <tt>roleName</tt> is null
*
* @throws IllegalStateException if the {@link ServletContext} from
* which this ServletRegistration was obtained has already been
* initialized
*/
public void setRunAsRole(String roleName);
}
}
|
jboss/jboss-servlet-api_spec
|
src/main/java/javax/servlet/ServletRegistration.java
|
Java
|
gpl-2.0
| 9,714 |
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-marshal-byteswap.h Swap a block of marshaled data
*
* Copyright (C) 2005 Red Hat, Inc.
*
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef DBUS_MARSHAL_BYTESWAP_H
#define DBUS_MARSHAL_BYTESWAP_H
#include <config.h>
#include <dbus/dbus-protocol.h>
#include <dbus/dbus-marshal-recursive.h>
#ifndef PACKAGE
#error "config.h not included here"
#endif
void _dbus_marshal_byteswap (const DBusString *signature,
int signature_start,
int old_byte_order,
int new_byte_order,
DBusString *value_str,
int value_pos);
#endif /* DBUS_MARSHAL_BYTESWAP_H */
|
wooshy1/android-tegra-nv-2.6.39
|
atheros/src/AR6kSDK-CAF/AR6kSDK.2.2.1.151/host/tools/athbtfilter.bk/athbtfilter/host/tools/athbtfilter/bluez/dbus/dbus-marshal-byteswap.h
|
C
|
gpl-2.0
| 1,546 |
<!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/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
margin-top: 0px;
background-image: url(Buchanan-bkgd.jpg);
}
</style>
</head>
<body>
<div align="center"><img src="images/Buchanan-BARGE-specifics.jpg" width="988" height="1399" usemap="#Map" border="0" />
<map name="Map" id="Map"><area shape="rect" coords="579,1285,667,1303" href="buchanan-contact.html" />
<area shape="rect" coords="435,1365,602,1390" href="uswt.html" />
<area shape="rect" coords="329,102,385,129" href="buchanan.html" />
<area shape="rect" coords="14,37,436,74" href="buchanan.html" />
<area shape="rect" coords="417,104,578,129" href="BM-mission-statement.html" />
<area shape="rect" coords="156,1257,204,1274" href="buchanan.html" />
<area shape="rect" coords="219,1254,366,1274" href="BM-mission-statement.html" />
<area shape="rect" coords="377,1254,547,1275" href="buchanan-tug-specifics.html" />
<area shape="rect" coords="818,106,897,127" href="BM-at-work.html" />
<area shape="rect" coords="556,1255,804,1274" href="BM-at-work.html" />
<area shape="rect" coords="337,1284,572,1305" href="buchanan-careers.html" />
<area shape="rect" coords="927,105,974,127" href="buchanan-docs.html" />
<area shape="rect" coords="813,1255,859,1275" href="buchanan-docs.html" />
<area shape="rect" coords="32,172,395,218" href="buchanan-tug-specifics.html" />
</map>
</div>
</body>
</html>
|
Studio-Center/demos.studiocenter.com
|
tugs/buchanan-barge-specifics.html
|
HTML
|
gpl-2.0
| 1,669 |
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2020 SUSE LLC
* Author: Nicolai Stange <[email protected]>
* LTP port: Martin Doucha <[email protected]>
*/
/*\
* CVE-2020-25705
*
* Test of ICMP rate limiting behavior that may be abused for DNS cache
* poisoning attack. Send a few batches of 100 packets to a closed UDP port
* and count the ICMP errors. If the number of errors is always the same
* for each batch (not randomized), the system is vulnerable. Send packets
* from multiple IP addresses to bypass per-address ICMP throttling.
*
* Fixed in:
*
* commit b38e7819cae946e2edf869e604af1e65a5d241c5
* Author: Eric Dumazet <[email protected]>
* Date: Thu Oct 15 11:42:00 2020 -0700
*
* icmp: randomize the global rate limiter
*/
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/errqueue.h>
#include <sched.h>
#include <limits.h>
#include "lapi/if_addr.h"
#include "tst_test.h"
#include "tst_netdevice.h"
#define DSTNET 0xfa444e00 /* 250.68.78.0 */
#define SRCNET 0xfa444e40 /* 250.68.78.64 */
#define DSTADDR 0xfa444e02 /* 250.68.78.2 */
#define SRCADDR_BASE 0xfa444e41 /* 250.68.78.65 */
#define SRCADDR_COUNT 50
#define NETMASK 26
#define BATCH_COUNT 8
#define BUFSIZE 1024
static int parentns = -1, childns = -1;
static int fds[SRCADDR_COUNT];
static void setup(void)
{
struct sockaddr_in ipaddr = { .sin_family = AF_INET };
uint32_t addr;
int i;
int real_uid = getuid();
int real_gid = getgid();
for (i = 0; i < SRCADDR_COUNT; i++)
fds[i] = -1;
SAFE_TRY_FILE_PRINTF("/proc/sys/user/max_user_namespaces", "%d", 10);
SAFE_UNSHARE(CLONE_NEWUSER);
SAFE_UNSHARE(CLONE_NEWNET);
SAFE_FILE_PRINTF("/proc/self/setgroups", "deny");
SAFE_FILE_PRINTF("/proc/self/uid_map", "0 %d 1\n", real_uid);
SAFE_FILE_PRINTF("/proc/self/gid_map", "0 %d 1\n", real_gid);
/*
* Create network namespace to hide the destination interface from
* the test process.
*/
parentns = SAFE_OPEN("/proc/self/ns/net", O_RDONLY);
SAFE_UNSHARE(CLONE_NEWNET);
/* Do NOT close this FD, or both interfaces will be destroyed */
childns = SAFE_OPEN("/proc/self/ns/net", O_RDONLY);
/* Configure child namespace */
CREATE_VETH_PAIR("ltp_veth1", "ltp_veth2");
NETDEV_ADD_ADDRESS_INET("ltp_veth2", htonl(DSTADDR), NETMASK,
IFA_F_NOPREFIXROUTE);
NETDEV_SET_STATE("ltp_veth2", 1);
NETDEV_ADD_ROUTE_INET("ltp_veth2", 0, 0, htonl(SRCNET), NETMASK, 0);
/* Configure parent namespace */
NETDEV_CHANGE_NS_FD("ltp_veth1", parentns);
SAFE_SETNS(parentns, CLONE_NEWNET);
addr = SRCADDR_BASE;
for (i = 0; i < SRCADDR_COUNT; i++, addr++) {
NETDEV_ADD_ADDRESS_INET("ltp_veth1", htonl(addr), NETMASK,
IFA_F_NOPREFIXROUTE);
}
NETDEV_SET_STATE("ltp_veth1", 1);
NETDEV_ADD_ROUTE_INET("ltp_veth1", 0, 0, htonl(DSTNET), NETMASK, 0);
SAFE_FILE_PRINTF("/proc/sys/net/ipv4/conf/ltp_veth1/forwarding", "1");
/* Open test sockets */
for (i = 0; i < SRCADDR_COUNT; i++) {
ipaddr.sin_addr.s_addr = htonl(SRCADDR_BASE + i);
fds[i] = SAFE_SOCKET(AF_INET, SOCK_DGRAM, 0);
SAFE_SETSOCKOPT_INT(fds[i], IPPROTO_IP, IP_RECVERR, 1);
SAFE_BIND(fds[i], (struct sockaddr *)&ipaddr, sizeof(ipaddr));
}
}
static int count_icmp_errors(int fd)
{
int error_count = 0;
ssize_t len;
char msgbuf[BUFSIZE], errbuf[BUFSIZE];
struct sockaddr_in addr;
struct cmsghdr *cmsg;
struct sock_extended_err exterr;
struct iovec iov = {
.iov_base = msgbuf,
.iov_len = BUFSIZE
};
while (1) {
struct msghdr msg = {
.msg_name = (struct sockaddr *)&addr,
.msg_namelen = sizeof(addr),
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_flags = 0,
.msg_control = errbuf,
.msg_controllen = BUFSIZE
};
memset(errbuf, 0, BUFSIZE);
errno = 0;
len = recvmsg(fd, &msg, MSG_ERRQUEUE);
if (len == -1) {
if (errno == EWOULDBLOCK || errno == EAGAIN)
break;
tst_brk(TBROK | TERRNO, "recvmsg() failed");
}
if (len < 0) {
tst_brk(TBROK | TERRNO,
"Invalid recvmsg() return value %zd", len);
}
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg;
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_IP)
continue;
if (cmsg->cmsg_type != IP_RECVERR)
continue;
memcpy(&exterr, CMSG_DATA(cmsg), sizeof(exterr));
if (exterr.ee_origin != SO_EE_ORIGIN_ICMP)
tst_brk(TBROK, "Unexpected non-ICMP error");
if (exterr.ee_errno != ECONNREFUSED) {
TST_ERR = exterr.ee_errno;
tst_brk(TBROK | TTERRNO,
"Unexpected ICMP error");
}
error_count++;
}
}
return error_count;
}
static int packet_batch(const struct sockaddr *addr, socklen_t addrsize)
{
int i, j, error_count = 0;
char data = 0;
for (i = 0; i < SRCADDR_COUNT; i++) {
for (j = 0; j < 2; j++) {
error_count += count_icmp_errors(fds[i]);
TEST(sendto(fds[i], &data, sizeof(data), 0, addr,
addrsize));
if (TST_RET == -1) {
if (TST_ERR == ECONNREFUSED) {
j--; /* flush ICMP errors and retry */
continue;
}
tst_brk(TBROK | TTERRNO, "sento() failed");
}
if (TST_RET < 0) {
tst_brk(TBROK | TTERRNO,
"Invalid sento() return value %ld",
TST_RET);
}
}
}
/*
* Wait and collect pending ICMP errors. Waiting less than 2 seconds
* will make the test unreliable. Looping over each socket multiple
* times (with or without poll()) will cause kernel to silently
* discard ICMP errors, allowing the test to pass on vulnerable
* systems.
*/
sleep(2);
for (i = 0; i < SRCADDR_COUNT; i++)
error_count += count_icmp_errors(fds[i]);
return error_count;
}
static void run(void)
{
int i, errors_baseline, errors;
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_port = TST_GET_UNUSED_PORT(AF_INET, SOCK_DGRAM),
.sin_addr = { htonl(DSTADDR) }
};
errors_baseline = packet_batch((struct sockaddr *)&addr, sizeof(addr));
errors = errors_baseline;
tst_res(TINFO, "Batch 0: Got %d ICMP errors", errors);
for (i = 1; i < BATCH_COUNT && errors == errors_baseline; i++) {
errors = packet_batch((struct sockaddr *)&addr, sizeof(addr));
tst_res(TINFO, "Batch %d: Got %d ICMP errors", i, errors);
}
if (errors == errors_baseline) {
tst_res(TFAIL,
"ICMP rate limit not randomized, system is vulnerable");
return;
}
tst_res(TPASS, "ICMP rate limit is randomized");
}
static void cleanup(void)
{
int i;
for (i = 0; i < SRCADDR_COUNT; i++)
if (fds[i] >= 0)
SAFE_CLOSE(fds[i]);
if (childns >= 0)
SAFE_CLOSE(childns);
if (parentns >= 0)
SAFE_CLOSE(parentns);
}
static struct tst_test test = {
.test_all = run,
.setup = setup,
.cleanup = cleanup,
.needs_kconfigs = (const char *[]) {
"CONFIG_VETH",
"CONFIG_USER_NS=y",
"CONFIG_NET_NS=y",
NULL
},
.save_restore = (const char * const[]) {
"?/proc/sys/user/max_user_namespaces",
NULL,
},
.tags = (const struct tst_tag[]) {
{"linux-git", "b38e7819cae9"},
{"CVE", "2020-25705"},
{}
}
};
|
linux-test-project/ltp
|
testcases/cve/icmp_rate_limit01.c
|
C
|
gpl-2.0
| 6,879 |
import time, logging
from autotest.client.shared import error
from autotest.client import utils
from virttest import utils_misc
from qemu.tests import drive_mirror
class DriveMirrorStress(drive_mirror.DriveMirror):
def __init__(self, test, params, env, tag):
super(DriveMirrorStress, self).__init__(test, params, env, tag)
@error.context_aware
def install_stress_app(self):
error.context("install stress app in guest")
params = self.parser_test_args()
session = self.get_session()
installed = session.cmd_status(params.get("app_check_cmd")) == 0
if installed:
return
link = params.get("download_link")
md5sum = params.get("md5sum")
tmp_dir = params.get("tmp_dir")
install_cmd = params.get("install_cmd") % tmp_dir
config_cmd = params.get("config_cmd")
pkg = utils.unmap_url_cache(self.test.tmpdir, link, md5sum)
self.vm.copy_files_to(pkg, tmp_dir)
s, o = session.cmd_status_output(install_cmd, timeout=300)
if s != 0:
raise error.TestError("Fail to install stress app(%s)" % o)
s, o = session.cmd_status_output(config_cmd, timeout=300)
if s != 0:
raise error.TestError("Fail to conifg stress app(%s)" % o)
@error.context_aware
def load_stress(self):
"""
load IO/CPU/Memory stress in guest;
"""
params = self.parser_test_args()
self.install_stress_app()
cmd = params.get("start_cmd")
session = self.get_session()
error.context("launch stress app in guest", logging.info)
session.sendline(cmd)
logging.info("Command: %s" % cmd)
runing = utils_misc.wait_for(self.app_runing, first=0.5, timeout=300)
if not runing:
raise error.TestFail("stress app isn't running")
return None
@error.context_aware
def unload_stress(self):
"""
stop stress app
"""
def _unload_stress():
params = self.parser_test_args()
session = self.get_session()
cmd = params.get("stop_cmd")
session.sendline(cmd)
if not self.app_runing():
return True
return False
error.context("stop stress app in guest", logging.info)
utils_misc.wait_for(_unload_stress, first=2.0,
text="wait stress app quit", step=1.0, timeout=120)
def app_runing(self):
"""
check stress app really run in background;
"""
session = self.get_session()
params = self.parser_test_args()
cmd = params.get("check_cmd")
status = session.cmd_status(cmd, timeout=120)
return status == 0
@error.context_aware
def verify_steady(self):
"""
verify offset not decreased, after block mirror job in steady status;
"""
error.context("verify offset not decreased", logging.info)
params = self.parser_test_args()
timeout = int(params.get("hold_on_timeout", 600))
offset = self.get_status()["offset"]
start = time.time()
while time.time() < start + timeout:
_offset = self.get_status()["offset"]
if _offset < offset:
msg = "offset decreased, offset last: %s" % offset
msg += "offset now: %s" % _offset
raise error.TestFail(msg)
offset = _offset
def run_drive_mirror_stress(test, params, env):
"""
drive_mirror_stress test:
1). load stress in guest
2). mirror block device
3). stop vm when mirroring job really run(optional)
4). wait for block job in steady status
5). check offset not decreased(optional)
6). reopen new target image(optional)
7). quit stress app, reboot guest(optional);
8). verify guest can response correctly
@param test: QEMU test object
@param params: Dictionary with the test parameters
@param env: Dictionary with test environment.
"""
tag = params.get("source_image", "image1")
stress_test = DriveMirrorStress(test, params, env, tag)
try:
stress_test.action_before_start()
stress_test.start()
stress_test.action_before_steady()
stress_test.action_when_steady()
stress_test.action_after_reopen()
finally:
stress_test.clean()
|
rbbratta/virt-test
|
qemu/tests/drive_mirror_stress.py
|
Python
|
gpl-2.0
| 4,397 |
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* Metacity Theme Rendering */
/*
* Copyright (C) 2001 Havoc Pennington
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef META_THEME_PRIVATE_H
#define META_THEME_PRIVATE_H
#include <meta/boxes.h>
#include <meta/gradient.h>
#include <meta/theme.h>
#include <meta/common.h>
#include <gtk/gtk.h>
/**
* MetaFrameStyle: (skip)
*
*/
typedef struct _MetaFrameStyle MetaFrameStyle;
/**
* MetaFrameStyleSet: (skip)
*
*/
typedef struct _MetaFrameStyleSet MetaFrameStyleSet;
/**
* MetaDrawOp: (skip)
*
*/
typedef struct _MetaDrawOp MetaDrawOp;
/**
* MetaDrawOpList: (skip)
*
*/
typedef struct _MetaDrawOpList MetaDrawOpList;
/**
* MetaGradientSpec: (skip)
*
*/
typedef struct _MetaGradientSpec MetaGradientSpec;
/**
* MetaAlphaGradientSpec: (skip)
*
*/
typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec;
/**
* MetaColorSpec: (skip)
*
*/
typedef struct _MetaColorSpec MetaColorSpec;
/**
* MetaFrameLayout: (skip)
*
*/
typedef struct _MetaFrameLayout MetaFrameLayout;
/**
* MetaButtonSpace: (skip)
*
*/
typedef struct _MetaButtonSpace MetaButtonSpace;
/**
* MetaFrameGeometry: (skip)
*
*/
typedef struct _MetaFrameGeometry MetaFrameGeometry;
/**
* MetaPositionExprEnv: (skip)
*
*/
typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
/**
* MetaDrawInfo: (skip)
*
*/
typedef struct _MetaDrawInfo MetaDrawInfo;
#define META_THEME_ERROR (g_quark_from_static_string ("meta-theme-error"))
typedef enum
{
META_THEME_ERROR_FRAME_GEOMETRY,
META_THEME_ERROR_BAD_CHARACTER,
META_THEME_ERROR_BAD_PARENS,
META_THEME_ERROR_UNKNOWN_VARIABLE,
META_THEME_ERROR_DIVIDE_BY_ZERO,
META_THEME_ERROR_MOD_ON_FLOAT,
META_THEME_ERROR_FAILED
} MetaThemeError;
/**
* Whether a button's size is calculated from the area around it (aspect
* sizing) or is given as a fixed height and width in pixels (fixed sizing).
*
* \bug This could be done away with; see the comment at the top of
* MetaFrameLayout.
*/
typedef enum
{
META_BUTTON_SIZING_ASPECT,
META_BUTTON_SIZING_FIXED,
META_BUTTON_SIZING_LAST
} MetaButtonSizing;
/**
* Various parameters used to calculate the geometry of a frame.
* They are used inside a MetaFrameStyle.
* This corresponds closely to the <frame_geometry> tag in a theme file.
*
* \bug button_sizing isn't really necessary, because we could easily say
* that if button_aspect is zero, the height and width are fixed values.
* This would also mean that MetaButtonSizing didn't need to exist, and
* save code.
**/
struct _MetaFrameLayout
{
/** Reference count. */
int refcount;
/** Size of left side */
int left_width;
/** Size of right side */
int right_width;
/** Size of bottom side */
int bottom_height;
/** Border of blue title region
* \bug (blue?!)
**/
GtkBorder title_border;
/** Extra height for inside of title region, above the font height */
int title_vertical_pad;
/** Right indent of buttons from edges of frame */
int right_titlebar_edge;
/** Left indent of buttons from edges of frame */
int left_titlebar_edge;
/**
* Sizing rule of buttons, either META_BUTTON_SIZING_ASPECT
* (in which case button_aspect will be honoured, and
* button_width and button_height set from it), or
* META_BUTTON_SIZING_FIXED (in which case we read the width
* and height directly).
*/
MetaButtonSizing button_sizing;
/**
* Ratio of height/width. Honoured only if
* button_sizing==META_BUTTON_SIZING_ASPECT.
* Otherwise we figure out the height from the button_border.
*/
double button_aspect;
/** Width of a button; set even when we are using aspect sizing */
int button_width;
/** Height of a button; set even when we are using aspect sizing */
int button_height;
/** Space around buttons */
GtkBorder button_border;
/** scale factor for title text */
double title_scale;
/** Whether title text will be displayed */
guint has_title : 1;
/** Whether we should hide the buttons */
guint hide_buttons : 1;
/** Radius of the top left-hand corner; 0 if not rounded */
guint top_left_corner_rounded_radius;
/** Radius of the top right-hand corner; 0 if not rounded */
guint top_right_corner_rounded_radius;
/** Radius of the bottom left-hand corner; 0 if not rounded */
guint bottom_left_corner_rounded_radius;
/** Radius of the bottom right-hand corner; 0 if not rounded */
guint bottom_right_corner_rounded_radius;
};
/**
* The computed size of a button (really just a way of tying its
* visible and clickable areas together).
* The reason for two different rectangles here is Fitts' law & maximized
* windows; see bug #97703 for more details.
*/
struct _MetaButtonSpace
{
/** The screen area where the button's image is drawn */
GdkRectangle visible;
/** The screen area where the button can be activated by clicking */
GdkRectangle clickable;
};
/**
* Calculated actual geometry of the frame
*/
struct _MetaFrameGeometry
{
MetaFrameBorders borders;
int width;
int height;
GdkRectangle title_rect;
int left_titlebar_edge;
int right_titlebar_edge;
int top_titlebar_edge;
int bottom_titlebar_edge;
/* used for a memset hack */
#define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
#define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, right_single_background) + sizeof (GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
/* The button rects (if changed adjust memset hack) */
MetaButtonSpace close_rect;
MetaButtonSpace max_rect;
MetaButtonSpace min_rect;
MetaButtonSpace menu_rect;
MetaButtonSpace shade_rect;
MetaButtonSpace above_rect;
MetaButtonSpace stick_rect;
MetaButtonSpace unshade_rect;
MetaButtonSpace unabove_rect;
MetaButtonSpace unstick_rect;
#define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2)
GdkRectangle left_left_background;
GdkRectangle left_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
GdkRectangle left_right_background;
GdkRectangle left_single_background;
GdkRectangle right_left_background;
GdkRectangle right_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
GdkRectangle right_right_background;
GdkRectangle right_single_background;
/* End of button rects (if changed adjust memset hack) */
/* Saved button layout */
MetaButtonLayout button_layout;
int n_left_buttons;
int n_right_buttons;
/* Round corners */
guint top_left_corner_rounded_radius;
guint top_right_corner_rounded_radius;
guint bottom_left_corner_rounded_radius;
guint bottom_right_corner_rounded_radius;
};
typedef enum
{
META_IMAGE_FILL_SCALE, /* default, needs to be all-bits-zero for g_new0 */
META_IMAGE_FILL_TILE
} MetaImageFillType;
typedef enum
{
META_COLOR_SPEC_BASIC,
META_COLOR_SPEC_GTK,
META_COLOR_SPEC_GTK_CUSTOM,
META_COLOR_SPEC_BLEND,
META_COLOR_SPEC_SHADE
} MetaColorSpecType;
typedef enum
{
META_GTK_COLOR_FG,
META_GTK_COLOR_BG,
META_GTK_COLOR_LIGHT,
META_GTK_COLOR_DARK,
META_GTK_COLOR_MID,
META_GTK_COLOR_TEXT,
META_GTK_COLOR_BASE,
META_GTK_COLOR_TEXT_AA,
META_GTK_COLOR_LAST
} MetaGtkColorComponent;
struct _MetaColorSpec
{
MetaColorSpecType type;
union
{
struct {
GdkRGBA color;
} basic;
struct {
MetaGtkColorComponent component;
GtkStateFlags state;
} gtk;
struct {
char *color_name;
MetaColorSpec *fallback;
} gtkcustom;
struct {
MetaColorSpec *foreground;
MetaColorSpec *background;
double alpha;
GdkRGBA color;
} blend;
struct {
MetaColorSpec *base;
double factor;
GdkRGBA color;
} shade;
} data;
};
struct _MetaGradientSpec
{
MetaGradientType type;
GSList *color_specs;
};
struct _MetaAlphaGradientSpec
{
MetaGradientType type;
unsigned char *alphas;
int n_alphas;
};
struct _MetaDrawInfo
{
GdkPixbuf *mini_icon;
GdkPixbuf *icon;
PangoLayout *title_layout;
int title_layout_width;
int title_layout_height;
const MetaFrameGeometry *fgeom;
};
/**
* A drawing operation in our simple vector drawing language.
*/
typedef enum
{
/** Basic drawing-- line */
META_DRAW_LINE,
/** Basic drawing-- rectangle */
META_DRAW_RECTANGLE,
/** Basic drawing-- arc */
META_DRAW_ARC,
/** Clip to a rectangle */
META_DRAW_CLIP,
/* Texture thingies */
/** Just a filled rectangle with alpha */
META_DRAW_TINT,
META_DRAW_GRADIENT,
META_DRAW_IMAGE,
/** GTK theme engine stuff */
META_DRAW_GTK_ARROW,
META_DRAW_GTK_BOX,
META_DRAW_GTK_VLINE,
/** App's window icon */
META_DRAW_ICON,
/** App's window title */
META_DRAW_TITLE,
/** a draw op list */
META_DRAW_OP_LIST,
/** tiled draw op list */
META_DRAW_TILE
} MetaDrawType;
typedef enum
{
POS_TOKEN_INT,
POS_TOKEN_DOUBLE,
POS_TOKEN_OPERATOR,
POS_TOKEN_VARIABLE,
POS_TOKEN_OPEN_PAREN,
POS_TOKEN_CLOSE_PAREN
} PosTokenType;
typedef enum
{
POS_OP_NONE,
POS_OP_ADD,
POS_OP_SUBTRACT,
POS_OP_MULTIPLY,
POS_OP_DIVIDE,
POS_OP_MOD,
POS_OP_MAX,
POS_OP_MIN
} PosOperatorType;
/**
* A token, as output by the tokeniser.
*
* \ingroup tokenizer
*/
typedef struct
{
PosTokenType type;
union
{
struct {
int val;
} i;
struct {
double val;
} d;
struct {
PosOperatorType op;
} o;
struct {
char *name;
GQuark name_quark;
} v;
} d;
} PosToken;
/**
* MetaDrawSpec: (skip)
*
* A computed expression in our simple vector drawing language.
* While it appears to take the form of a tree, this is actually
* merely a list; concerns such as precedence of operators are
* currently recomputed on every recalculation.
*
* Created by meta_draw_spec_new(), destroyed by meta_draw_spec_free().
* pos_eval() fills this with ...FIXME. Are tokens a tree or a list?
* \ingroup parser
*/
typedef struct _MetaDrawSpec MetaDrawSpec;
struct _MetaDrawSpec
{
/**
* If this spec is constant, this is the value of the constant;
* otherwise it is zero.
*/
int value;
/** A list of tokens in the expression. */
PosToken *tokens;
/** How many tokens are in the tokens list. */
int n_tokens;
/** Does the expression contain any variables? */
gboolean constant : 1;
};
/**
* A single drawing operation in our simple vector drawing language.
*/
struct _MetaDrawOp
{
MetaDrawType type;
/* Positions are strings because they can be expressions */
union
{
struct {
MetaColorSpec *color_spec;
int dash_on_length;
int dash_off_length;
int width;
MetaDrawSpec *x1;
MetaDrawSpec *y1;
MetaDrawSpec *x2;
MetaDrawSpec *y2;
} line;
struct {
MetaColorSpec *color_spec;
gboolean filled;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} rectangle;
struct {
MetaColorSpec *color_spec;
gboolean filled;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
double start_angle;
double extent_angle;
} arc;
struct {
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} clip;
struct {
MetaColorSpec *color_spec;
MetaAlphaGradientSpec *alpha_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} tint;
struct {
MetaGradientSpec *gradient_spec;
MetaAlphaGradientSpec *alpha_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} gradient;
struct {
MetaColorSpec *colorize_spec;
MetaAlphaGradientSpec *alpha_spec;
GdkPixbuf *pixbuf;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
guint32 colorize_cache_pixel;
GdkPixbuf *colorize_cache_pixbuf;
MetaImageFillType fill_type;
unsigned int vertical_stripes : 1;
unsigned int horizontal_stripes : 1;
} image;
struct {
GtkStateFlags state;
GtkShadowType shadow;
GtkArrowType arrow;
gboolean filled;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} gtk_arrow;
struct {
GtkStateFlags state;
GtkShadowType shadow;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} gtk_box;
struct {
GtkStateFlags state;
MetaDrawSpec *x;
MetaDrawSpec *y1;
MetaDrawSpec *y2;
} gtk_vline;
struct {
MetaAlphaGradientSpec *alpha_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
MetaImageFillType fill_type;
} icon;
struct {
MetaColorSpec *color_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *ellipsize_width;
} title;
struct {
MetaDrawOpList *op_list;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} op_list;
struct {
MetaDrawOpList *op_list;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
MetaDrawSpec *tile_xoffset;
MetaDrawSpec *tile_yoffset;
MetaDrawSpec *tile_width;
MetaDrawSpec *tile_height;
} tile;
} data;
};
/**
* A list of MetaDrawOp objects. Maintains a reference count.
* Grows as necessary and allows the allocation of unused spaces
* to keep reallocations to a minimum.
*
* \bug Do we really win anything from not using the equivalent
* GLib structures?
*/
struct _MetaDrawOpList
{
int refcount;
MetaDrawOp **ops;
int n_ops;
int n_allocated;
};
typedef enum
{
META_BUTTON_STATE_NORMAL,
META_BUTTON_STATE_PRESSED,
META_BUTTON_STATE_PRELIGHT,
META_BUTTON_STATE_LAST
} MetaButtonState;
typedef enum
{
/* Ordered so that background is drawn first */
META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND,
META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND,
META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND,
META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND,
META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND,
META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND,
META_BUTTON_TYPE_CLOSE,
META_BUTTON_TYPE_MAXIMIZE,
META_BUTTON_TYPE_MINIMIZE,
META_BUTTON_TYPE_MENU,
META_BUTTON_TYPE_SHADE,
META_BUTTON_TYPE_ABOVE,
META_BUTTON_TYPE_STICK,
META_BUTTON_TYPE_UNSHADE,
META_BUTTON_TYPE_UNABOVE,
META_BUTTON_TYPE_UNSTICK,
META_BUTTON_TYPE_LAST
} MetaButtonType;
typedef enum
{
META_MENU_ICON_TYPE_CLOSE,
META_MENU_ICON_TYPE_MAXIMIZE,
META_MENU_ICON_TYPE_UNMAXIMIZE,
META_MENU_ICON_TYPE_MINIMIZE,
META_MENU_ICON_TYPE_LAST
} MetaMenuIconType;
typedef enum
{
/* Listed in the order in which the textures are drawn.
* (though this only matters for overlaps of course.)
* Buttons are drawn after the frame textures.
*
* On the corners, horizontal pieces are arbitrarily given the
* corner area:
*
* ===== |====
* | |
* | rather than |
*
*/
/* entire frame */
META_FRAME_PIECE_ENTIRE_BACKGROUND,
/* entire titlebar background */
META_FRAME_PIECE_TITLEBAR,
/* portion of the titlebar background inside the titlebar
* background edges
*/
META_FRAME_PIECE_TITLEBAR_MIDDLE,
/* left end of titlebar */
META_FRAME_PIECE_LEFT_TITLEBAR_EDGE,
/* right end of titlebar */
META_FRAME_PIECE_RIGHT_TITLEBAR_EDGE,
/* top edge of titlebar */
META_FRAME_PIECE_TOP_TITLEBAR_EDGE,
/* bottom edge of titlebar */
META_FRAME_PIECE_BOTTOM_TITLEBAR_EDGE,
/* render over title background (text area) */
META_FRAME_PIECE_TITLE,
/* left edge of the frame */
META_FRAME_PIECE_LEFT_EDGE,
/* right edge of the frame */
META_FRAME_PIECE_RIGHT_EDGE,
/* bottom edge of the frame */
META_FRAME_PIECE_BOTTOM_EDGE,
/* place over entire frame, after drawing everything else */
META_FRAME_PIECE_OVERLAY,
/* Used to get size of the enum */
META_FRAME_PIECE_LAST
} MetaFramePiece;
/**
* How to draw a frame in a particular state (say, a focussed, non-maximised,
* resizable frame). This corresponds closely to the <frame_style> tag
* in a theme file.
*/
struct _MetaFrameStyle
{
/** Reference count. */
int refcount;
/**
* Parent style.
* Settings which are unspecified here will be taken from there.
*/
MetaFrameStyle *parent;
/** Operations for drawing each kind of button in each state. */
MetaDrawOpList *buttons[META_BUTTON_TYPE_LAST][META_BUTTON_STATE_LAST];
/** Operations for drawing each piece of the frame. */
MetaDrawOpList *pieces[META_FRAME_PIECE_LAST];
/**
* Details such as the height and width of each edge, the corner rounding,
* and the aspect ratio of the buttons.
*/
MetaFrameLayout *layout;
/**
* Background colour of the window. Only present in theme formats
* 2 and above. Can be NULL to use the standard GTK theme engine.
*/
MetaColorSpec *window_background_color;
/**
* Transparency of the window background. 0=transparent; 255=opaque.
*/
guint8 window_background_alpha;
};
/* Kinds of frame...
*
* normal -> noresize / vert only / horz only / both
* focused / unfocused
* max -> focused / unfocused
* shaded -> focused / unfocused
* max/shaded -> focused / unfocused
*
* so 4 states with 8 sub-states in one, 2 sub-states in the other 3,
* meaning 14 total
*
* 14 window states times 7 or 8 window types. Except some
* window types never get a frame so that narrows it down a bit.
*
*/
typedef enum
{
META_FRAME_STATE_NORMAL,
META_FRAME_STATE_MAXIMIZED,
META_FRAME_STATE_TILED_LEFT,
META_FRAME_STATE_TILED_RIGHT,
META_FRAME_STATE_SHADED,
META_FRAME_STATE_MAXIMIZED_AND_SHADED,
META_FRAME_STATE_TILED_LEFT_AND_SHADED,
META_FRAME_STATE_TILED_RIGHT_AND_SHADED,
META_FRAME_STATE_LAST
} MetaFrameState;
typedef enum
{
META_FRAME_RESIZE_NONE,
META_FRAME_RESIZE_VERTICAL,
META_FRAME_RESIZE_HORIZONTAL,
META_FRAME_RESIZE_BOTH,
META_FRAME_RESIZE_LAST
} MetaFrameResize;
typedef enum
{
META_FRAME_FOCUS_NO,
META_FRAME_FOCUS_YES,
META_FRAME_FOCUS_LAST
} MetaFrameFocus;
/**
* How to draw frames at different times: when it's maximised or not, shaded
* or not, when it's focussed or not, and (for non-maximised windows), when
* it can be horizontally or vertically resized, both, or neither.
* Not all window types actually get a frame.
*
* A theme contains one of these objects for each type of window (each
* MetaFrameType), that is, normal, dialogue (modal and non-modal), etc.
*
* This corresponds closely to the <frame_style_set> tag in a theme file.
*/
struct _MetaFrameStyleSet
{
int refcount;
MetaFrameStyleSet *parent;
MetaFrameStyle *normal_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
MetaFrameStyle *maximized_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_left_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_right_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *shaded_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
MetaFrameStyle *maximized_and_shaded_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_left_and_shaded_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_right_and_shaded_styles[META_FRAME_FOCUS_LAST];
};
/**
* A theme. This is a singleton class which groups all settings from a theme
* on disk together.
*
* \bug It is rather useless to keep the metadata fields in core, I think.
*/
struct _MetaTheme
{
/** Name of the theme (on disk), e.g. "Crux" */
char *name;
/** Path to the files associated with the theme */
char *dirname;
/**
* Filename of the XML theme file.
* \bug Kept lying around for no discernable reason.
*/
char *filename;
/** Metadata: Human-readable name of the theme. */
char *readable_name;
/** Metadata: Author of the theme. */
char *author;
/** Metadata: Copyright holder. */
char *copyright;
/** Metadata: Date of the theme. */
char *date;
/** Metadata: Description of the theme. */
char *description;
/** Version of the theme format. Older versions cannot use the features
* of newer versions even if they think they can (this is to allow forward
* and backward compatibility.
*/
guint format_version;
/** Symbol table of integer constants. */
GHashTable *integer_constants;
/** Symbol table of float constants. */
GHashTable *float_constants;
/**
* Symbol table of colour constants (hex triples, and triples
* plus alpha).
* */
GHashTable *color_constants;
GHashTable *images_by_filename;
GHashTable *layouts_by_name;
GHashTable *draw_op_lists_by_name;
GHashTable *styles_by_name;
GHashTable *style_sets_by_name;
MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST];
GQuark quark_width;
GQuark quark_height;
GQuark quark_object_width;
GQuark quark_object_height;
GQuark quark_left_width;
GQuark quark_right_width;
GQuark quark_top_height;
GQuark quark_bottom_height;
GQuark quark_mini_icon_width;
GQuark quark_mini_icon_height;
GQuark quark_icon_width;
GQuark quark_icon_height;
GQuark quark_title_width;
GQuark quark_title_height;
GQuark quark_frame_x_center;
GQuark quark_frame_y_center;
};
struct _MetaPositionExprEnv
{
MetaRectangle rect;
/* size of an object being drawn, if it has a natural size */
int object_width;
int object_height;
/* global object sizes, always available */
int left_width;
int right_width;
int top_height;
int bottom_height;
int title_width;
int title_height;
int frame_x_center;
int frame_y_center;
int mini_icon_width;
int mini_icon_height;
int icon_width;
int icon_height;
/* Theme so we can look up constants */
MetaTheme *theme;
};
MetaFrameLayout* meta_frame_layout_new (void);
MetaFrameLayout* meta_frame_layout_copy (const MetaFrameLayout *src);
void meta_frame_layout_ref (MetaFrameLayout *layout);
void meta_frame_layout_unref (MetaFrameLayout *layout);
void meta_frame_layout_get_borders (const MetaFrameLayout *layout,
int text_height,
MetaFrameFlags flags,
MetaFrameType type,
MetaFrameBorders *borders);
gboolean meta_frame_layout_validate (const MetaFrameLayout *layout,
GError **error);
gboolean meta_parse_position_expression (MetaDrawSpec *spec,
const MetaPositionExprEnv *env,
int *x_return,
int *y_return,
GError **err);
gboolean meta_parse_size_expression (MetaDrawSpec *spec,
const MetaPositionExprEnv *env,
int *val_return,
GError **err);
MetaDrawSpec* meta_draw_spec_new (MetaTheme *theme,
const char *expr,
GError **error);
void meta_draw_spec_free (MetaDrawSpec *spec);
MetaColorSpec* meta_color_spec_new (MetaColorSpecType type);
MetaColorSpec* meta_color_spec_new_from_string (const char *str,
GError **err);
MetaColorSpec* meta_color_spec_new_gtk (MetaGtkColorComponent component,
GtkStateFlags state);
void meta_color_spec_free (MetaColorSpec *spec);
void meta_color_spec_render (MetaColorSpec *spec,
GtkStyleContext *style_gtk,
GdkRGBA *color);
MetaDrawOp* meta_draw_op_new (MetaDrawType type);
void meta_draw_op_free (MetaDrawOp *op);
void meta_draw_op_draw_with_style (const MetaDrawOp *op,
GtkStyleContext *style_gtk,
cairo_t *cr,
const MetaDrawInfo *info,
/* logical region being drawn */
MetaRectangle logical_region);
MetaDrawOpList* meta_draw_op_list_new (int n_preallocs);
void meta_draw_op_list_ref (MetaDrawOpList *op_list);
void meta_draw_op_list_unref (MetaDrawOpList *op_list);
void meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
GtkStyleContext *style_gtk,
cairo_t *cr,
const MetaDrawInfo *info,
MetaRectangle rect);
void meta_draw_op_list_append (MetaDrawOpList *op_list,
MetaDrawOp *op);
gboolean meta_draw_op_list_validate (MetaDrawOpList *op_list,
GError **error);
gboolean meta_draw_op_list_contains (MetaDrawOpList *op_list,
MetaDrawOpList *child);
MetaGradientSpec* meta_gradient_spec_new (MetaGradientType type);
void meta_gradient_spec_free (MetaGradientSpec *desc);
GdkPixbuf* meta_gradient_spec_render (const MetaGradientSpec *desc,
GtkStyleContext *gtk_style,
int width,
int height);
gboolean meta_gradient_spec_validate (MetaGradientSpec *spec,
GError **error);
MetaAlphaGradientSpec* meta_alpha_gradient_spec_new (MetaGradientType type,
int n_alphas);
void meta_alpha_gradient_spec_free (MetaAlphaGradientSpec *spec);
MetaFrameStyle* meta_frame_style_new (MetaFrameStyle *parent);
void meta_frame_style_ref (MetaFrameStyle *style);
void meta_frame_style_unref (MetaFrameStyle *style);
gboolean meta_frame_style_validate (MetaFrameStyle *style,
guint current_theme_version,
GError **error);
MetaFrameStyleSet* meta_frame_style_set_new (MetaFrameStyleSet *parent);
void meta_frame_style_set_ref (MetaFrameStyleSet *style_set);
void meta_frame_style_set_unref (MetaFrameStyleSet *style_set);
gboolean meta_frame_style_set_validate (MetaFrameStyleSet *style_set,
GError **error);
GdkPixbuf* meta_theme_load_image (MetaTheme *theme,
const char *filename,
guint size_of_theme_icons,
GError **error);
MetaFrameStyle* meta_theme_get_frame_style (MetaTheme *theme,
MetaFrameType type,
MetaFrameFlags flags);
double meta_theme_get_title_scale (MetaTheme *theme,
MetaFrameType type,
MetaFrameFlags flags);
GtkStyleContext * meta_theme_create_style_context (GdkScreen *screen,
const gchar *variant);
void meta_theme_draw_frame (MetaTheme *theme,
GtkStyleContext *style_gtk,
cairo_t *cr,
MetaFrameType type,
MetaFrameFlags flags,
int client_width,
int client_height,
PangoLayout *title_layout,
int text_height,
const MetaButtonLayout *button_layout,
MetaButtonState button_states[META_BUTTON_TYPE_LAST],
GdkPixbuf *mini_icon,
GdkPixbuf *icon);
void meta_theme_get_frame_borders (MetaTheme *theme,
MetaFrameType type,
int text_height,
MetaFrameFlags flags,
MetaFrameBorders *borders);
void meta_theme_calc_geometry (MetaTheme *theme,
MetaFrameType type,
int text_height,
MetaFrameFlags flags,
int client_width,
int client_height,
const MetaButtonLayout *button_layout,
MetaFrameGeometry *fgeom);
MetaFrameLayout* meta_theme_lookup_layout (MetaTheme *theme,
const char *name);
void meta_theme_insert_layout (MetaTheme *theme,
const char *name,
MetaFrameLayout *layout);
MetaDrawOpList* meta_theme_lookup_draw_op_list (MetaTheme *theme,
const char *name);
void meta_theme_insert_draw_op_list (MetaTheme *theme,
const char *name,
MetaDrawOpList *op_list);
MetaFrameStyle* meta_theme_lookup_style (MetaTheme *theme,
const char *name);
void meta_theme_insert_style (MetaTheme *theme,
const char *name,
MetaFrameStyle *style);
MetaFrameStyleSet* meta_theme_lookup_style_set (MetaTheme *theme,
const char *name);
void meta_theme_insert_style_set (MetaTheme *theme,
const char *name,
MetaFrameStyleSet *style_set);
gboolean meta_theme_define_int_constant (MetaTheme *theme,
const char *name,
int value,
GError **error);
gboolean meta_theme_lookup_int_constant (MetaTheme *theme,
const char *name,
int *value);
gboolean meta_theme_define_float_constant (MetaTheme *theme,
const char *name,
double value,
GError **error);
gboolean meta_theme_lookup_float_constant (MetaTheme *theme,
const char *name,
double *value);
gboolean meta_theme_define_color_constant (MetaTheme *theme,
const char *name,
const char *value,
GError **error);
gboolean meta_theme_lookup_color_constant (MetaTheme *theme,
const char *name,
char **value);
gboolean meta_theme_replace_constants (MetaTheme *theme,
PosToken *tokens,
int n_tokens,
GError **err);
/* random stuff */
PangoFontDescription* meta_gtk_widget_get_font_desc (GtkWidget *widget,
double scale,
const PangoFontDescription *override);
int meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc,
PangoContext *context);
/* Enum converters */
MetaGtkColorComponent meta_color_component_from_string (const char *str);
MetaButtonState meta_button_state_from_string (const char *str);
const char* meta_button_state_to_string (MetaButtonState state);
MetaButtonType meta_button_type_from_string (const char *str,
MetaTheme *theme);
const char* meta_button_type_to_string (MetaButtonType type);
MetaFramePiece meta_frame_piece_from_string (const char *str);
MetaFrameState meta_frame_state_from_string (const char *str);
const char* meta_frame_state_to_string (MetaFrameState state);
MetaFrameResize meta_frame_resize_from_string (const char *str);
const char* meta_frame_resize_to_string (MetaFrameResize resize);
MetaFrameFocus meta_frame_focus_from_string (const char *str);
const char* meta_frame_focus_to_string (MetaFrameFocus focus);
MetaFrameType meta_frame_type_from_string (const char *str);
MetaGradientType meta_gradient_type_from_string (const char *str);
GtkStateFlags meta_gtk_state_from_string (const char *str);
GtkShadowType meta_gtk_shadow_from_string (const char *str);
GtkArrowType meta_gtk_arrow_from_string (const char *str);
MetaImageFillType meta_image_fill_type_from_string (const char *str);
void meta_gtk_style_get_light_color (GtkStyleContext *style,
GtkStateFlags state,
GdkRGBA *color);
void meta_gtk_style_get_dark_color (GtkStyleContext *style,
GtkStateFlags state,
GdkRGBA *color);
guint meta_theme_earliest_version_with_button (MetaButtonType type);
#define META_THEME_ALLOWS(theme, feature) (theme->format_version >= feature)
/* What version of the theme file format were various features introduced in? */
#define META_THEME_SHADE_STICK_ABOVE_BUTTONS 2
#define META_THEME_UBIQUITOUS_CONSTANTS 2
#define META_THEME_VARIED_ROUND_CORNERS 2
#define META_THEME_IMAGES_FROM_ICON_THEMES 2
#define META_THEME_UNRESIZABLE_SHADED_STYLES 2
#define META_THEME_DEGREES_IN_ARCS 2
#define META_THEME_HIDDEN_BUTTONS 2
#define META_THEME_COLOR_CONSTANTS 2
#define META_THEME_FRAME_BACKGROUNDS 2
#endif /* META_THEME_PRIVATE_H */
|
gcampax/mutter
|
src/ui/theme-private.h
|
C
|
gpl-2.0
| 37,264 |
/* Copyright (c) 2012-2014, The Linux Foundation. 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/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/bug.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/device.h>
#include <linux/notifier.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/rbtree.h>
#include <soc/qcom/rpm-notifier.h>
#include <soc/qcom/rpm-smd.h>
#include <mach/msm_smd.h>
#define CREATE_TRACE_POINTS
#include <trace/events/trace_rpm_smd.h>
/* Debug Definitions */
enum {
MSM_RPM_LOG_REQUEST_PRETTY = BIT(0),
MSM_RPM_LOG_REQUEST_RAW = BIT(1),
MSM_RPM_LOG_REQUEST_SHOW_MSG_ID = BIT(2),
};
static int msm_rpm_debug_mask;
module_param_named(
debug_mask, msm_rpm_debug_mask, int, S_IRUGO | S_IWUSR
);
struct msm_rpm_driver_data {
const char *ch_name;
uint32_t ch_type;
smd_channel_t *ch_info;
struct work_struct work;
spinlock_t smd_lock_write;
spinlock_t smd_lock_read;
struct completion smd_open;
struct completion remote_open;
};
#define DEFAULT_BUFFER_SIZE 256
#define DEBUG_PRINT_BUFFER_SIZE 512
#define MAX_SLEEP_BUFFER 128
#define SMD_CHANNEL_NOTIF_TIMEOUT 5000
#define GFP_FLAG(noirq) (noirq ? GFP_ATOMIC : GFP_KERNEL)
#define INV_RSC "resource does not exist"
#define ERR "err\0"
#define MAX_ERR_BUFFER_SIZE 128
#define MAX_WAIT_ON_ACK 24
#define INIT_ERROR 1
static ATOMIC_NOTIFIER_HEAD(msm_rpm_sleep_notifier);
static bool standalone;
int msm_rpm_register_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_register(&msm_rpm_sleep_notifier, nb);
}
int msm_rpm_unregister_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_unregister(&msm_rpm_sleep_notifier, nb);
}
static struct workqueue_struct *msm_rpm_smd_wq;
enum {
MSM_RPM_MSG_REQUEST_TYPE = 0,
MSM_RPM_MSG_TYPE_NR,
};
static const uint32_t msm_rpm_request_service[MSM_RPM_MSG_TYPE_NR] = {
0x716572, /* 'req\0' */
};
/*the order of fields matter and reflect the order expected by the RPM*/
struct rpm_request_header {
uint32_t service_type;
uint32_t request_len;
};
struct rpm_message_header {
uint32_t msg_id;
enum msm_rpm_set set;
uint32_t resource_type;
uint32_t resource_id;
uint32_t data_len;
};
struct kvp {
unsigned int k;
unsigned int s;
};
struct msm_rpm_kvp_data {
uint32_t key;
uint32_t nbytes; /* number of bytes */
uint8_t *value;
bool valid;
};
struct slp_buf {
struct rb_node node;
char ubuf[MAX_SLEEP_BUFFER];
char *buf;
bool valid;
};
static struct rb_root tr_root = RB_ROOT;
static int msm_rpm_send_smd_buffer(char *buf, uint32_t size, bool noirq);
static uint32_t msm_rpm_get_next_msg_id(void);
static inline unsigned int get_rsc_type(char *buf)
{
struct rpm_message_header *h;
h = (struct rpm_message_header *)
(buf + sizeof(struct rpm_request_header));
return h->resource_type;
}
static inline unsigned int get_rsc_id(char *buf)
{
struct rpm_message_header *h;
h = (struct rpm_message_header *)
(buf + sizeof(struct rpm_request_header));
return h->resource_id;
}
#define get_data_len(buf) \
(((struct rpm_message_header *) \
(buf + sizeof(struct rpm_request_header)))->data_len)
#define get_req_len(buf) \
(((struct rpm_request_header *)(buf))->request_len)
#define get_msg_id(buf) \
(((struct rpm_message_header *) \
(buf + sizeof(struct rpm_request_header)))->msg_id)
static inline int get_buf_len(char *buf)
{
return get_req_len(buf) + sizeof(struct rpm_request_header);
}
static inline struct kvp *get_first_kvp(char *buf)
{
return (struct kvp *)(buf + sizeof(struct rpm_request_header)
+ sizeof(struct rpm_message_header));
}
static inline struct kvp *get_next_kvp(struct kvp *k)
{
return (struct kvp *)((void *)k + sizeof(*k) + k->s);
}
static inline void *get_data(struct kvp *k)
{
return (void *)k + sizeof(*k);
}
static void delete_kvp(char *msg, struct kvp *d)
{
struct kvp *n;
int dec;
uint32_t size;
n = get_next_kvp(d);
dec = (void *)n - (void *)d;
size = get_data_len(msg) - ((void *)n - (void *)get_first_kvp(msg));
memcpy((void *)d, (void *)n, size);
get_data_len(msg) -= dec;
get_req_len(msg) -= dec;
}
static inline void update_kvp_data(struct kvp *dest, struct kvp *src)
{
memcpy(get_data(dest), get_data(src), src->s);
}
static void add_kvp(char *buf, struct kvp *n)
{
uint32_t inc = sizeof(*n) + n->s;
BUG_ON((get_req_len(buf) + inc) > MAX_SLEEP_BUFFER);
memcpy(buf + get_buf_len(buf), n, inc);
get_data_len(buf) += inc;
get_req_len(buf) += inc;
}
static struct slp_buf *tr_search(struct rb_root *root, char *slp)
{
unsigned int type = get_rsc_type(slp);
unsigned int id = get_rsc_id(slp);
struct rb_node *node = root->rb_node;
while (node) {
struct slp_buf *cur = rb_entry(node, struct slp_buf, node);
unsigned int ctype = get_rsc_type(cur->buf);
unsigned int cid = get_rsc_id(cur->buf);
if (type < ctype)
node = node->rb_left;
else if (type > ctype)
node = node->rb_right;
else if (id < cid)
node = node->rb_left;
else if (id > cid)
node = node->rb_right;
else
return cur;
}
return NULL;
}
static int tr_insert(struct rb_root *root, struct slp_buf *slp)
{
unsigned int type = get_rsc_type(slp->buf);
unsigned int id = get_rsc_id(slp->buf);
struct rb_node **node = &(root->rb_node), *parent = NULL;
while (*node) {
struct slp_buf *curr = rb_entry(*node, struct slp_buf, node);
unsigned int ctype = get_rsc_type(curr->buf);
unsigned int cid = get_rsc_id(curr->buf);
parent = *node;
if (type < ctype)
node = &((*node)->rb_left);
else if (type > ctype)
node = &((*node)->rb_right);
else if (id < cid)
node = &((*node)->rb_left);
else if (id > cid)
node = &((*node)->rb_right);
else
return -EINVAL;
}
rb_link_node(&slp->node, parent, node);
rb_insert_color(&slp->node, root);
slp->valid = true;
return 0;
}
#define for_each_kvp(buf, k) \
for (k = (struct kvp *)get_first_kvp(buf); \
((void *)k - (void *)get_first_kvp(buf)) < get_data_len(buf);\
k = get_next_kvp(k))
static void tr_update(struct slp_buf *s, char *buf)
{
struct kvp *e, *n;
for_each_kvp(buf, n) {
bool found = false;
for_each_kvp(s->buf, e) {
if (n->k == e->k) {
found = true;
if (n->s == e->s) {
void *e_data = get_data(e);
void *n_data = get_data(n);
if (memcmp(e_data, n_data, n->s)) {
update_kvp_data(e, n);
s->valid = true;
}
} else {
delete_kvp(s->buf, e);
add_kvp(s->buf, n);
s->valid = true;
}
break;
}
}
if (!found) {
add_kvp(s->buf, n);
s->valid = true;
}
}
}
int msm_rpm_smd_buffer_request(char *buf, uint32_t size, gfp_t flag)
{
struct slp_buf *slp;
static DEFINE_SPINLOCK(slp_buffer_lock);
unsigned long flags;
if (size > MAX_SLEEP_BUFFER)
return -ENOMEM;
spin_lock_irqsave(&slp_buffer_lock, flags);
slp = tr_search(&tr_root, buf);
if (!slp) {
slp = kzalloc(sizeof(struct slp_buf), GFP_ATOMIC);
if (!slp) {
spin_unlock_irqrestore(&slp_buffer_lock, flags);
return -ENOMEM;
}
slp->buf = PTR_ALIGN(&slp->ubuf[0], sizeof(u32));
memcpy(slp->buf, buf, size);
if (tr_insert(&tr_root, slp))
pr_err("%s(): Error updating sleep request\n",
__func__);
} else {
/* handle unsent requests */
tr_update(slp, buf);
}
spin_unlock_irqrestore(&slp_buffer_lock, flags);
return 0;
}
static void msm_rpm_print_sleep_buffer(struct slp_buf *s)
{
char buf[DEBUG_PRINT_BUFFER_SIZE] = {0};
int pos;
int buflen = DEBUG_PRINT_BUFFER_SIZE;
char ch[5] = {0};
u32 type;
struct kvp *e;
if (!s)
return;
if (!s->valid)
return;
type = get_rsc_type(s->buf);
memcpy(ch, &type, sizeof(u32));
pos = scnprintf(buf, buflen,
"Sleep request type = 0x%08x(%s)",
get_rsc_type(s->buf), ch);
pos += scnprintf(buf + pos, buflen - pos, " id = 0%x",
get_rsc_id(s->buf));
for_each_kvp(s->buf, e) {
uint32_t i;
char *data = get_data(e);
memcpy(ch, &e->k, sizeof(u32));
pos += scnprintf(buf + pos, buflen - pos,
"\n\t\tkey = 0x%08x(%s)",
e->k, ch);
pos += scnprintf(buf + pos, buflen - pos,
" sz= %d data =", e->s);
for (i = 0; i < e->s; i++)
pos += scnprintf(buf + pos, buflen - pos,
" 0x%02X", data[i]);
}
pos += scnprintf(buf + pos, buflen - pos, "\n");
printk(buf);
}
static struct msm_rpm_driver_data msm_rpm_data = {
.smd_open = COMPLETION_INITIALIZER(msm_rpm_data.smd_open),
};
static int msm_rpm_flush_requests(bool print)
{
struct rb_node *t;
int ret;
int pkt_sz;
char buf[MAX_ERR_BUFFER_SIZE] = {0};
int count = 0;
for (t = rb_first(&tr_root); t; t = rb_next(t)) {
struct slp_buf *s = rb_entry(t, struct slp_buf, node);
if (!s->valid)
continue;
if (print)
msm_rpm_print_sleep_buffer(s);
get_msg_id(s->buf) = msm_rpm_get_next_msg_id();
ret = msm_rpm_send_smd_buffer(s->buf,
get_buf_len(s->buf), true);
/*
* RPM acks need to be handled here if we have sent over
* 24 messages such that we do not overrun SMD buffer. Since
* we expect only sleep sets at this point (RPM PC would be
* disallowed if we had pending active requests), we need not
* process these sleep set acks.
*/
count++;
if (count > MAX_WAIT_ON_ACK) {
int len;
pkt_sz = smd_cur_packet_size(msm_rpm_data.ch_info);
if (pkt_sz)
len = smd_read(msm_rpm_data.ch_info, buf,
pkt_sz);
count--;
}
WARN_ON(ret != get_buf_len(s->buf));
trace_rpm_send_message(true, MSM_RPM_CTX_SLEEP_SET,
get_rsc_type(s->buf),
get_rsc_id(s->buf),
get_msg_id(s->buf));
s->valid = false;
}
return 0;
}
static atomic_t msm_rpm_msg_id = ATOMIC_INIT(0);
struct msm_rpm_request {
struct rpm_request_header req_hdr;
struct rpm_message_header msg_hdr;
struct msm_rpm_kvp_data *kvp;
uint32_t num_elements;
uint32_t write_idx;
uint8_t *buf;
uint32_t numbytes;
};
/*
* Data related to message acknowledgement
*/
LIST_HEAD(msm_rpm_wait_list);
struct msm_rpm_wait_data {
struct list_head list;
uint32_t msg_id;
bool ack_recd;
int errno;
struct completion ack;
};
DEFINE_SPINLOCK(msm_rpm_list_lock);
struct msm_rpm_ack_msg {
uint32_t req;
uint32_t req_len;
uint32_t rsc_id;
uint32_t msg_len;
uint32_t id_ack;
};
LIST_HEAD(msm_rpm_ack_list);
static DECLARE_COMPLETION(data_ready);
static void msm_rpm_notify_sleep_chain(struct rpm_message_header *hdr,
struct msm_rpm_kvp_data *kvp)
{
struct msm_rpm_notifier_data notif;
notif.rsc_type = hdr->resource_type;
notif.rsc_id = hdr->resource_id;
notif.key = kvp->key;
notif.size = kvp->nbytes;
notif.value = kvp->value;
atomic_notifier_call_chain(&msm_rpm_sleep_notifier, 0, ¬if);
}
static int msm_rpm_add_kvp_data_common(struct msm_rpm_request *handle,
uint32_t key, const uint8_t *data, int size, bool noirq)
{
uint32_t i;
uint32_t data_size, msg_size;
if (!handle) {
pr_err("%s(): Invalid handle\n", __func__);
return -EINVAL;
}
if (size < 0)
return -EINVAL;
data_size = ALIGN(size, SZ_4);
msg_size = data_size + sizeof(struct rpm_request_header);
for (i = 0; i < handle->write_idx; i++) {
if (handle->kvp[i].key != key)
continue;
if (handle->kvp[i].nbytes != data_size) {
kfree(handle->kvp[i].value);
handle->kvp[i].value = NULL;
} else {
if (!memcmp(handle->kvp[i].value, data, data_size))
return 0;
}
break;
}
if (i >= handle->num_elements) {
pr_err("%s(): Number of resources exceeds max allocated\n",
__func__);
return -ENOMEM;
}
if (i == handle->write_idx)
handle->write_idx++;
if (!handle->kvp[i].value) {
handle->kvp[i].value = kzalloc(data_size, GFP_FLAG(noirq));
if (!handle->kvp[i].value) {
pr_err("%s(): Failed malloc\n", __func__);
return -ENOMEM;
}
} else {
/* We enter the else case, if a key already exists but the
* data doesn't match. In which case, we should zero the data
* out.
*/
memset(handle->kvp[i].value, 0, data_size);
}
if (!handle->kvp[i].valid)
handle->msg_hdr.data_len += msg_size;
else
handle->msg_hdr.data_len += (data_size - handle->kvp[i].nbytes);
handle->kvp[i].nbytes = data_size;
handle->kvp[i].key = key;
memcpy(handle->kvp[i].value, data, size);
handle->kvp[i].valid = true;
return 0;
}
static struct msm_rpm_request *msm_rpm_create_request_common(
enum msm_rpm_set set, uint32_t rsc_type, uint32_t rsc_id,
int num_elements, bool noirq)
{
struct msm_rpm_request *cdata;
cdata = kzalloc(sizeof(struct msm_rpm_request),
GFP_FLAG(noirq));
if (!cdata) {
printk(KERN_INFO"%s():Cannot allocate memory for client data\n",
__func__);
goto cdata_alloc_fail;
}
cdata->msg_hdr.set = set;
cdata->msg_hdr.resource_type = rsc_type;
cdata->msg_hdr.resource_id = rsc_id;
cdata->msg_hdr.data_len = 0;
cdata->num_elements = num_elements;
cdata->write_idx = 0;
cdata->kvp = kzalloc(sizeof(struct msm_rpm_kvp_data) * num_elements,
GFP_FLAG(noirq));
if (!cdata->kvp) {
pr_warn("%s(): Cannot allocate memory for key value data\n",
__func__);
goto kvp_alloc_fail;
}
cdata->buf = kzalloc(DEFAULT_BUFFER_SIZE, GFP_FLAG(noirq));
if (!cdata->buf)
goto buf_alloc_fail;
cdata->numbytes = DEFAULT_BUFFER_SIZE;
return cdata;
buf_alloc_fail:
kfree(cdata->kvp);
kvp_alloc_fail:
kfree(cdata);
cdata_alloc_fail:
return NULL;
}
void msm_rpm_free_request(struct msm_rpm_request *handle)
{
int i;
if (!handle)
return;
for (i = 0; i < handle->num_elements; i++)
kfree(handle->kvp[i].value);
kfree(handle->kvp);
kfree(handle->buf);
kfree(handle);
}
EXPORT_SYMBOL(msm_rpm_free_request);
struct msm_rpm_request *msm_rpm_create_request(
enum msm_rpm_set set, uint32_t rsc_type,
uint32_t rsc_id, int num_elements)
{
return msm_rpm_create_request_common(set, rsc_type, rsc_id,
num_elements, false);
}
EXPORT_SYMBOL(msm_rpm_create_request);
struct msm_rpm_request *msm_rpm_create_request_noirq(
enum msm_rpm_set set, uint32_t rsc_type,
uint32_t rsc_id, int num_elements)
{
return msm_rpm_create_request_common(set, rsc_type, rsc_id,
num_elements, true);
}
EXPORT_SYMBOL(msm_rpm_create_request_noirq);
int msm_rpm_add_kvp_data(struct msm_rpm_request *handle,
uint32_t key, const uint8_t *data, int size)
{
return msm_rpm_add_kvp_data_common(handle, key, data, size, false);
}
EXPORT_SYMBOL(msm_rpm_add_kvp_data);
int msm_rpm_add_kvp_data_noirq(struct msm_rpm_request *handle,
uint32_t key, const uint8_t *data, int size)
{
return msm_rpm_add_kvp_data_common(handle, key, data, size, true);
}
EXPORT_SYMBOL(msm_rpm_add_kvp_data_noirq);
/* Runs in interrupt context */
static void msm_rpm_notify(void *data, unsigned event)
{
struct msm_rpm_driver_data *pdata = (struct msm_rpm_driver_data *)data;
BUG_ON(!pdata);
if (!(pdata->ch_info))
return;
switch (event) {
case SMD_EVENT_DATA:
complete(&data_ready);
break;
case SMD_EVENT_OPEN:
complete(&pdata->smd_open);
break;
case SMD_EVENT_CLOSE:
case SMD_EVENT_STATUS:
case SMD_EVENT_REOPEN_READY:
break;
default:
pr_info("Unknown SMD event\n");
}
}
bool msm_rpm_waiting_for_ack(void)
{
bool ret;
unsigned long flags;
spin_lock_irqsave(&msm_rpm_list_lock, flags);
ret = list_empty(&msm_rpm_wait_list);
spin_unlock_irqrestore(&msm_rpm_list_lock, flags);
return !ret;
}
static struct msm_rpm_wait_data *msm_rpm_get_entry_from_msg_id(uint32_t msg_id)
{
struct list_head *ptr;
struct msm_rpm_wait_data *elem = NULL;
unsigned long flags;
spin_lock_irqsave(&msm_rpm_list_lock, flags);
list_for_each(ptr, &msm_rpm_wait_list) {
elem = list_entry(ptr, struct msm_rpm_wait_data, list);
if (elem && (elem->msg_id == msg_id))
break;
elem = NULL;
}
spin_unlock_irqrestore(&msm_rpm_list_lock, flags);
return elem;
}
static uint32_t msm_rpm_get_next_msg_id(void)
{
uint32_t id;
/*
* A message id of 0 is used by the driver to indicate a error
* condition. The RPM driver uses a id of 1 to indicate unsent data
* when the data sent over hasn't been modified. This isn't a error
* scenario and wait for ack returns a success when the message id is 1.
*/
do {
id = atomic_inc_return(&msm_rpm_msg_id);
} while ((id == 0) || (id == 1) || msm_rpm_get_entry_from_msg_id(id));
return id;
}
static int msm_rpm_add_wait_list(uint32_t msg_id)
{
unsigned long flags;
struct msm_rpm_wait_data *data =
kzalloc(sizeof(struct msm_rpm_wait_data), GFP_ATOMIC);
if (!data)
return -ENOMEM;
init_completion(&data->ack);
data->ack_recd = false;
data->msg_id = msg_id;
data->errno = INIT_ERROR;
spin_lock_irqsave(&msm_rpm_list_lock, flags);
list_add(&data->list, &msm_rpm_wait_list);
spin_unlock_irqrestore(&msm_rpm_list_lock, flags);
return 0;
}
static void msm_rpm_free_list_entry(struct msm_rpm_wait_data *elem)
{
unsigned long flags;
spin_lock_irqsave(&msm_rpm_list_lock, flags);
list_del(&elem->list);
spin_unlock_irqrestore(&msm_rpm_list_lock, flags);
kfree(elem);
}
static void msm_rpm_process_ack(uint32_t msg_id, int errno)
{
struct list_head *ptr;
struct msm_rpm_wait_data *elem = NULL;
unsigned long flags;
spin_lock_irqsave(&msm_rpm_list_lock, flags);
list_for_each(ptr, &msm_rpm_wait_list) {
elem = list_entry(ptr, struct msm_rpm_wait_data, list);
if (elem && (elem->msg_id == msg_id)) {
elem->errno = errno;
elem->ack_recd = true;
complete(&elem->ack);
break;
}
elem = NULL;
}
/* Special case where the sleep driver doesn't
* wait for ACKs. This would decrease the latency involved with
* entering RPM assisted power collapse.
*/
if (!elem)
trace_rpm_ack_recd(0, msg_id);
spin_unlock_irqrestore(&msm_rpm_list_lock, flags);
}
struct msm_rpm_kvp_packet {
uint32_t id;
uint32_t len;
uint32_t val;
};
static inline uint32_t msm_rpm_get_msg_id_from_ack(uint8_t *buf)
{
return ((struct msm_rpm_ack_msg *)buf)->id_ack;
}
static inline int msm_rpm_get_error_from_ack(uint8_t *buf)
{
uint8_t *tmp;
uint32_t req_len = ((struct msm_rpm_ack_msg *)buf)->req_len;
int rc = -ENODEV;
req_len -= sizeof(struct msm_rpm_ack_msg);
req_len += 2 * sizeof(uint32_t);
if (!req_len)
return 0;
tmp = buf + sizeof(struct msm_rpm_ack_msg);
BUG_ON(memcmp(tmp, ERR, sizeof(uint32_t)));
tmp += 2 * sizeof(uint32_t);
if (!(memcmp(tmp, INV_RSC, min_t(uint32_t, req_len,
sizeof(INV_RSC))-1))) {
pr_err("%s(): RPM NACK Unsupported resource\n", __func__);
rc = -EINVAL;
} else {
pr_err("%s(): RPM NACK Invalid header\n", __func__);
}
return rc;
}
static int msm_rpm_read_smd_data(char *buf)
{
uint32_t pkt_sz;
int bytes_read = 0;
pkt_sz = smd_cur_packet_size(msm_rpm_data.ch_info);
if (!pkt_sz)
return -EAGAIN;
BUG_ON(pkt_sz > MAX_ERR_BUFFER_SIZE);
if (pkt_sz != smd_read_avail(msm_rpm_data.ch_info))
return -EAGAIN;
do {
int len;
len = smd_read(msm_rpm_data.ch_info, buf + bytes_read, pkt_sz);
pkt_sz -= len;
bytes_read += len;
} while (pkt_sz > 0);
BUG_ON(pkt_sz < 0);
return 0;
}
static void msm_rpm_smd_work(struct work_struct *work)
{
uint32_t msg_id;
int errno;
char buf[MAX_ERR_BUFFER_SIZE] = {0};
while (1) {
wait_for_completion(&data_ready);
spin_lock(&msm_rpm_data.smd_lock_read);
while (smd_is_pkt_avail(msm_rpm_data.ch_info)) {
if (msm_rpm_read_smd_data(buf))
break;
msg_id = msm_rpm_get_msg_id_from_ack(buf);
errno = msm_rpm_get_error_from_ack(buf);
msm_rpm_process_ack(msg_id, errno);
}
spin_unlock(&msm_rpm_data.smd_lock_read);
}
}
static void msm_rpm_log_request(struct msm_rpm_request *cdata)
{
char buf[DEBUG_PRINT_BUFFER_SIZE];
size_t buflen = DEBUG_PRINT_BUFFER_SIZE;
char name[5];
u32 value;
uint32_t i;
int j, prev_valid;
int valid_count = 0;
int pos = 0;
name[4] = 0;
for (i = 0; i < cdata->write_idx; i++)
if (cdata->kvp[i].valid)
valid_count++;
pos += scnprintf(buf + pos, buflen - pos, "%sRPM req: ", KERN_INFO);
if (msm_rpm_debug_mask & MSM_RPM_LOG_REQUEST_SHOW_MSG_ID)
pos += scnprintf(buf + pos, buflen - pos, "msg_id=%u, ",
cdata->msg_hdr.msg_id);
pos += scnprintf(buf + pos, buflen - pos, "s=%s",
(cdata->msg_hdr.set == MSM_RPM_CTX_ACTIVE_SET ? "act" : "slp"));
if ((msm_rpm_debug_mask & MSM_RPM_LOG_REQUEST_PRETTY)
&& (msm_rpm_debug_mask & MSM_RPM_LOG_REQUEST_RAW)) {
/* Both pretty and raw formatting */
memcpy(name, &cdata->msg_hdr.resource_type, sizeof(uint32_t));
pos += scnprintf(buf + pos, buflen - pos,
", rsc_type=0x%08X (%s), rsc_id=%u; ",
cdata->msg_hdr.resource_type, name,
cdata->msg_hdr.resource_id);
for (i = 0, prev_valid = 0; i < cdata->write_idx; i++) {
if (!cdata->kvp[i].valid)
continue;
memcpy(name, &cdata->kvp[i].key, sizeof(uint32_t));
pos += scnprintf(buf + pos, buflen - pos,
"[key=0x%08X (%s), value=%s",
cdata->kvp[i].key, name,
(cdata->kvp[i].nbytes ? "0x" : "null"));
for (j = 0; j < cdata->kvp[i].nbytes; j++)
pos += scnprintf(buf + pos, buflen - pos,
"%02X ",
cdata->kvp[i].value[j]);
if (cdata->kvp[i].nbytes)
pos += scnprintf(buf + pos, buflen - pos, "(");
for (j = 0; j < cdata->kvp[i].nbytes; j += 4) {
value = 0;
memcpy(&value, &cdata->kvp[i].value[j],
min_t(uint32_t, sizeof(uint32_t),
cdata->kvp[i].nbytes - j));
pos += scnprintf(buf + pos, buflen - pos, "%u",
value);
if (j + 4 < cdata->kvp[i].nbytes)
pos += scnprintf(buf + pos,
buflen - pos, " ");
}
if (cdata->kvp[i].nbytes)
pos += scnprintf(buf + pos, buflen - pos, ")");
pos += scnprintf(buf + pos, buflen - pos, "]");
if (prev_valid + 1 < valid_count)
pos += scnprintf(buf + pos, buflen - pos, ", ");
prev_valid++;
}
} else if (msm_rpm_debug_mask & MSM_RPM_LOG_REQUEST_PRETTY) {
/* Pretty formatting only */
memcpy(name, &cdata->msg_hdr.resource_type, sizeof(uint32_t));
pos += scnprintf(buf + pos, buflen - pos, " %s %u; ", name,
cdata->msg_hdr.resource_id);
for (i = 0, prev_valid = 0; i < cdata->write_idx; i++) {
if (!cdata->kvp[i].valid)
continue;
memcpy(name, &cdata->kvp[i].key, sizeof(uint32_t));
pos += scnprintf(buf + pos, buflen - pos, "%s=%s",
name, (cdata->kvp[i].nbytes ? "" : "null"));
for (j = 0; j < cdata->kvp[i].nbytes; j += 4) {
value = 0;
memcpy(&value, &cdata->kvp[i].value[j],
min_t(uint32_t, sizeof(uint32_t),
cdata->kvp[i].nbytes - j));
pos += scnprintf(buf + pos, buflen - pos, "%u",
value);
if (j + 4 < cdata->kvp[i].nbytes)
pos += scnprintf(buf + pos,
buflen - pos, " ");
}
if (prev_valid + 1 < valid_count)
pos += scnprintf(buf + pos, buflen - pos, ", ");
prev_valid++;
}
} else {
/* Raw formatting only */
pos += scnprintf(buf + pos, buflen - pos,
", rsc_type=0x%08X, rsc_id=%u; ",
cdata->msg_hdr.resource_type,
cdata->msg_hdr.resource_id);
for (i = 0, prev_valid = 0; i < cdata->write_idx; i++) {
if (!cdata->kvp[i].valid)
continue;
pos += scnprintf(buf + pos, buflen - pos,
"[key=0x%08X, value=%s",
cdata->kvp[i].key,
(cdata->kvp[i].nbytes ? "0x" : "null"));
for (j = 0; j < cdata->kvp[i].nbytes; j++) {
pos += scnprintf(buf + pos, buflen - pos,
"%02X",
cdata->kvp[i].value[j]);
if (j + 1 < cdata->kvp[i].nbytes)
pos += scnprintf(buf + pos,
buflen - pos, " ");
}
pos += scnprintf(buf + pos, buflen - pos, "]");
if (prev_valid + 1 < valid_count)
pos += scnprintf(buf + pos, buflen - pos, ", ");
prev_valid++;
}
}
pos += scnprintf(buf + pos, buflen - pos, "\n");
printk(buf);
}
static int msm_rpm_send_smd_buffer(char *buf, uint32_t size, bool noirq)
{
unsigned long flags;
int ret;
spin_lock_irqsave(&msm_rpm_data.smd_lock_write, flags);
ret = smd_write_avail(msm_rpm_data.ch_info);
while ((ret = smd_write_avail(msm_rpm_data.ch_info)) < size) {
if (ret < 0)
break;
if (!noirq) {
spin_unlock_irqrestore(&msm_rpm_data.smd_lock_write,
flags);
cpu_relax();
spin_lock_irqsave(&msm_rpm_data.smd_lock_write, flags);
} else
udelay(5);
}
if (ret < 0) {
pr_err("%s(): SMD not initialized\n", __func__);
spin_unlock_irqrestore(&msm_rpm_data.smd_lock_write, flags);
return ret;
}
ret = smd_write(msm_rpm_data.ch_info, buf, size);
spin_unlock_irqrestore(&msm_rpm_data.smd_lock_write, flags);
return ret;
}
static int msm_rpm_send_data(struct msm_rpm_request *cdata,
int msg_type, bool noirq)
{
uint8_t *tmpbuff;
int ret;
uint32_t i;
uint32_t msg_size;
int req_hdr_sz, msg_hdr_sz;
if (!cdata->msg_hdr.data_len)
return 1;
req_hdr_sz = sizeof(cdata->req_hdr);
msg_hdr_sz = sizeof(cdata->msg_hdr);
cdata->req_hdr.service_type = msm_rpm_request_service[msg_type];
cdata->req_hdr.request_len = cdata->msg_hdr.data_len + msg_hdr_sz;
msg_size = cdata->req_hdr.request_len + req_hdr_sz;
/* populate data_len */
if (msg_size > cdata->numbytes) {
kfree(cdata->buf);
cdata->numbytes = msg_size;
cdata->buf = kzalloc(msg_size, GFP_FLAG(noirq));
}
if (!cdata->buf) {
pr_err("%s(): Failed malloc\n", __func__);
return 0;
}
tmpbuff = cdata->buf;
tmpbuff += req_hdr_sz + msg_hdr_sz;
for (i = 0; (i < cdata->write_idx); i++) {
/* Sanity check */
BUG_ON((tmpbuff - cdata->buf) > cdata->numbytes);
if (!cdata->kvp[i].valid)
continue;
memcpy(tmpbuff, &cdata->kvp[i].key, sizeof(uint32_t));
tmpbuff += sizeof(uint32_t);
memcpy(tmpbuff, &cdata->kvp[i].nbytes, sizeof(uint32_t));
tmpbuff += sizeof(uint32_t);
memcpy(tmpbuff, cdata->kvp[i].value, cdata->kvp[i].nbytes);
tmpbuff += cdata->kvp[i].nbytes;
if (cdata->msg_hdr.set == MSM_RPM_CTX_SLEEP_SET)
msm_rpm_notify_sleep_chain(&cdata->msg_hdr,
&cdata->kvp[i]);
}
memcpy(cdata->buf, &cdata->req_hdr, req_hdr_sz + msg_hdr_sz);
if ((cdata->msg_hdr.set == MSM_RPM_CTX_SLEEP_SET) &&
!msm_rpm_smd_buffer_request(cdata->buf, msg_size,
GFP_FLAG(noirq)))
return 1;
cdata->msg_hdr.msg_id = msm_rpm_get_next_msg_id();
memcpy(cdata->buf + req_hdr_sz, &cdata->msg_hdr, msg_hdr_sz);
if (msm_rpm_debug_mask
& (MSM_RPM_LOG_REQUEST_PRETTY | MSM_RPM_LOG_REQUEST_RAW))
msm_rpm_log_request(cdata);
if (standalone) {
for (i = 0; (i < cdata->write_idx); i++)
cdata->kvp[i].valid = false;
cdata->msg_hdr.data_len = 0;
ret = cdata->msg_hdr.msg_id;
return ret;
}
msm_rpm_add_wait_list(cdata->msg_hdr.msg_id);
ret = msm_rpm_send_smd_buffer(&cdata->buf[0], msg_size, noirq);
if (ret == msg_size) {
trace_rpm_send_message(noirq, cdata->msg_hdr.set,
cdata->msg_hdr.resource_type,
cdata->msg_hdr.resource_id,
cdata->msg_hdr.msg_id);
for (i = 0; (i < cdata->write_idx); i++)
cdata->kvp[i].valid = false;
cdata->msg_hdr.data_len = 0;
ret = cdata->msg_hdr.msg_id;
} else if (ret < msg_size) {
struct msm_rpm_wait_data *rc;
ret = 0;
pr_err("Failed to write data msg_size:%d ret:%d\n",
msg_size, ret);
rc = msm_rpm_get_entry_from_msg_id(cdata->msg_hdr.msg_id);
if (rc)
msm_rpm_free_list_entry(rc);
}
return ret;
}
int msm_rpm_send_request(struct msm_rpm_request *handle)
{
int ret;
static DEFINE_MUTEX(send_mtx);
mutex_lock(&send_mtx);
ret = msm_rpm_send_data(handle, MSM_RPM_MSG_REQUEST_TYPE, false);
mutex_unlock(&send_mtx);
return ret;
}
EXPORT_SYMBOL(msm_rpm_send_request);
int msm_rpm_send_request_noirq(struct msm_rpm_request *handle)
{
return msm_rpm_send_data(handle, MSM_RPM_MSG_REQUEST_TYPE, true);
}
EXPORT_SYMBOL(msm_rpm_send_request_noirq);
int msm_rpm_wait_for_ack(uint32_t msg_id)
{
struct msm_rpm_wait_data *elem;
int rc = 0;
if (!msg_id) {
pr_err("%s(): Invalid msg id\n", __func__);
return -ENOMEM;
}
if (msg_id == 1)
return rc;
if (standalone)
return rc;
elem = msm_rpm_get_entry_from_msg_id(msg_id);
if (!elem)
return rc;
wait_for_completion(&elem->ack);
trace_rpm_ack_recd(0, msg_id);
rc = elem->errno;
msm_rpm_free_list_entry(elem);
return rc;
}
EXPORT_SYMBOL(msm_rpm_wait_for_ack);
int msm_rpm_wait_for_ack_noirq(uint32_t msg_id)
{
struct msm_rpm_wait_data *elem;
unsigned long flags;
int rc = 0;
uint32_t id = 0;
if (!msg_id) {
pr_err("%s(): Invalid msg id\n", __func__);
return -ENOMEM;
}
if (msg_id == 1)
return 0;
if (standalone)
return 0;
spin_lock_irqsave(&msm_rpm_data.smd_lock_read, flags);
elem = msm_rpm_get_entry_from_msg_id(msg_id);
if (!elem)
/* Should this be a bug
* Is it ok for another thread to read the msg?
*/
goto wait_ack_cleanup;
if (elem->errno != INIT_ERROR) {
rc = elem->errno;
msm_rpm_free_list_entry(elem);
goto wait_ack_cleanup;
}
while (id != msg_id) {
if (smd_is_pkt_avail(msm_rpm_data.ch_info)) {
int errno;
char buf[MAX_ERR_BUFFER_SIZE] = {};
msm_rpm_read_smd_data(buf);
id = msm_rpm_get_msg_id_from_ack(buf);
errno = msm_rpm_get_error_from_ack(buf);
msm_rpm_process_ack(id, errno);
}
}
rc = elem->errno;
trace_rpm_ack_recd(1, msg_id);
msm_rpm_free_list_entry(elem);
wait_ack_cleanup:
spin_unlock_irqrestore(&msm_rpm_data.smd_lock_read, flags);
if (smd_is_pkt_avail(msm_rpm_data.ch_info))
complete(&data_ready);
return rc;
}
EXPORT_SYMBOL(msm_rpm_wait_for_ack_noirq);
int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
{
int i, rc;
struct msm_rpm_request *req =
msm_rpm_create_request(set, rsc_type, rsc_id, nelems);
if (!req)
return -ENOMEM;
for (i = 0; i < nelems; i++) {
rc = msm_rpm_add_kvp_data(req, kvp[i].key,
kvp[i].data, kvp[i].length);
if (rc)
goto bail;
}
rc = msm_rpm_wait_for_ack(msm_rpm_send_request(req));
bail:
msm_rpm_free_request(req);
return rc;
}
EXPORT_SYMBOL(msm_rpm_send_message);
int msm_rpm_send_message_noirq(enum msm_rpm_set set, uint32_t rsc_type,
uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
{
int i, rc;
struct msm_rpm_request *req =
msm_rpm_create_request_noirq(set, rsc_type, rsc_id, nelems);
if (!req)
return -ENOMEM;
for (i = 0; i < nelems; i++) {
rc = msm_rpm_add_kvp_data_noirq(req, kvp[i].key,
kvp[i].data, kvp[i].length);
if (rc)
goto bail;
}
rc = msm_rpm_wait_for_ack_noirq(msm_rpm_send_request_noirq(req));
bail:
msm_rpm_free_request(req);
return rc;
}
EXPORT_SYMBOL(msm_rpm_send_message_noirq);
/**
* During power collapse, the rpm driver disables the SMD interrupts to make
* sure that the interrupt doesn't wakes us from sleep.
*/
int msm_rpm_enter_sleep(bool print, const struct cpumask *cpumask)
{
int ret = 0;
if (standalone)
return 0;
ret = smd_mask_receive_interrupt(msm_rpm_data.ch_info, true, cpumask);
if (!ret)
msm_rpm_flush_requests(print);
return ret;
}
EXPORT_SYMBOL(msm_rpm_enter_sleep);
/**
* When the system resumes from power collapse, the SMD interrupt disabled by
* enter function has to reenabled to continue processing SMD message.
*/
void msm_rpm_exit_sleep(void)
{
if (standalone)
return;
smd_mask_receive_interrupt(msm_rpm_data.ch_info, false, NULL);
}
EXPORT_SYMBOL(msm_rpm_exit_sleep);
static int msm_rpm_smd_remote_probe(struct platform_device *pdev)
{
if (pdev && pdev->id == msm_rpm_data.ch_type)
complete(&msm_rpm_data.remote_open);
return 0;
}
static struct platform_driver msm_rpm_smd_remote_driver = {
.probe = msm_rpm_smd_remote_probe,
.driver = {
.owner = THIS_MODULE,
},
};
static int msm_rpm_dev_probe(struct platform_device *pdev)
{
char *key = NULL;
int ret;
key = "rpm-channel-name";
ret = of_property_read_string(pdev->dev.of_node, key,
&msm_rpm_data.ch_name);
if (ret)
goto fail;
key = "rpm-channel-type";
ret = of_property_read_u32(pdev->dev.of_node, key,
&msm_rpm_data.ch_type);
if (ret)
goto fail;
key = "rpm-standalone";
standalone = of_property_read_bool(pdev->dev.of_node, key);
if (standalone)
goto skip_smd_init;
msm_rpm_smd_remote_driver.driver.name = msm_rpm_data.ch_name;
init_completion(&msm_rpm_data.remote_open);
spin_lock_init(&msm_rpm_data.smd_lock_write);
spin_lock_init(&msm_rpm_data.smd_lock_read);
INIT_WORK(&msm_rpm_data.work, msm_rpm_smd_work);
platform_driver_register(&msm_rpm_smd_remote_driver);
ret = wait_for_completion_timeout(&msm_rpm_data.remote_open,
msecs_to_jiffies(SMD_CHANNEL_NOTIF_TIMEOUT));
if (!ret || smd_named_open_on_edge(msm_rpm_data.ch_name,
msm_rpm_data.ch_type,
&msm_rpm_data.ch_info,
&msm_rpm_data,
msm_rpm_notify)) {
pr_info("Cannot open RPM channel %s %d\n", msm_rpm_data.ch_name,
msm_rpm_data.ch_type);
}
wait_for_completion(&msm_rpm_data.smd_open);
smd_disable_read_intr(msm_rpm_data.ch_info);
msm_rpm_smd_wq = alloc_workqueue("rpm-smd",
WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_HIGHPRI, 1);
if (!msm_rpm_smd_wq)
return -EINVAL;
queue_work(msm_rpm_smd_wq, &msm_rpm_data.work);
skip_smd_init:
of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
if (standalone)
pr_info("%s(): RPM running in standalone mode\n", __func__);
return 0;
fail:
pr_err("%s(): Failed to read node: %s, key=%s\n", __func__,
pdev->dev.of_node->full_name, key);
return -EINVAL;
}
static struct of_device_id msm_rpm_match_table[] = {
{.compatible = "qcom,rpm-smd"},
{},
};
static struct platform_driver msm_rpm_device_driver = {
.probe = msm_rpm_dev_probe,
.driver = {
.name = "rpm-smd",
.owner = THIS_MODULE,
.of_match_table = msm_rpm_match_table,
},
};
int __init msm_rpm_driver_init(void)
{
static bool registered;
if (registered)
return 0;
registered = true;
return platform_driver_register(&msm_rpm_device_driver);
}
EXPORT_SYMBOL(msm_rpm_driver_init);
late_initcall(msm_rpm_driver_init);
|
android-legacy/kernel
|
arch/arm/mach-msm/rpm-smd.c
|
C
|
gpl-2.0
| 34,080 |
/* linux/arch/arm/mach-s5pv210/include/mach/regs-hdmi.h
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*
* S5PV210 - Hdmi register header file for Samsung TVOut driver
*
* 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.
*/
#ifndef __ASM_ARCH_REGS_HDMI_H
#define __ASM_ARCH_REGS_HDMI_H __FILE__
#define S5P_I2C_HDMI_PHY_BASE(x) (x)
/*
* HDMI PHY is configured through the dedicated I2C.
* The dedicated I2C for HDMI PHY is only used as TX mode
* I2C-BUS Interface for HDMI PHY is internally connected
*/
#define I2C_HDMI_CON S5P_I2C_HDMI_PHY_BASE(0x0000)
#define I2C_HDMI_STAT S5P_I2C_HDMI_PHY_BASE(0x0004)
#define I2C_HDMI_ADD S5P_I2C_HDMI_PHY_BASE(0x0008)
#define I2C_HDMI_DS S5P_I2C_HDMI_PHY_BASE(0x000c)
#define I2C_HDMI_LC S5P_I2C_HDMI_PHY_BASE(0x0010)
#define S5P_HDMI_CTRL_BASE(x) (x)
#define S5P_HDMI_BASE(x) (x + 0x00010000)
#define S5P_HDMI_SPDIF_BASE(x) (x + 0x00030000)
#define S5P_HDMI_I2S_BASE(x) (x + 0x00040000)
#define S5P_HDMI_TG_BASE(x) (x + 0x00050000)
#define S5P_HDMI_EFUSE_BASE(x) (x + 0x00060000)
#define S5P_HDMI_CTRL_INTC_CON S5P_HDMI_CTRL_BASE(0x0000)
#define S5P_HDMI_CTRL_INTC_FLAG S5P_HDMI_CTRL_BASE(0x0004)
#define S5P_HDMI_CTRL_HDCP_KEY_LOAD S5P_HDMI_CTRL_BASE(0x0008)
#define S5P_HDMI_CTRL_HPD S5P_HDMI_CTRL_BASE(0x000C)
#define S5P_HDMI_CTRL_AUDIO_CLKSEL S5P_HDMI_CTRL_BASE(0x0010)
#define S5P_HDMI_CTRL_PHY_RSTOUT S5P_HDMI_CTRL_BASE(0x0014)
#define S5P_HDMI_CTRL_PHY_VPLL S5P_HDMI_CTRL_BASE(0x0018)
#define S5P_HDMI_CTRL_PHY_CMU S5P_HDMI_CTRL_BASE(0x001C)
#define S5P_HDMI_CTRL_CORE_RSTOUT S5P_HDMI_CTRL_BASE(0x0020)
#define S5P_HDMI_CON_0 S5P_HDMI_BASE(0x0000)
#define S5P_HDMI_CON_1 S5P_HDMI_BASE(0x0004)
#define S5P_HDMI_CON_2 S5P_HDMI_BASE(0x0008)
#define S5P_STATUS S5P_HDMI_BASE(0x0010)
#define HDMI_PHY_STATUS S5P_HDMI_BASE(0x0014)
#define S5P_STATUS_EN S5P_HDMI_BASE(0x0020)
#define S5P_HPD S5P_HDMI_BASE(0x0030)
#define S5P_MODE_SEL S5P_HDMI_BASE(0x0040)
#define S5P_ENC_EN S5P_HDMI_BASE(0x0044)
#define S5P_BLUE_SCREEN_0 S5P_HDMI_BASE(0x0050)
#define S5P_BLUE_SCREEN_1 S5P_HDMI_BASE(0x0054)
#define S5P_BLUE_SCREEN_2 S5P_HDMI_BASE(0x0058)
#define S5P_HDMI_YMAX S5P_HDMI_BASE(0x0060)
#define S5P_HDMI_YMIN S5P_HDMI_BASE(0x0064)
#define S5P_HDMI_CMAX S5P_HDMI_BASE(0x0068)
#define S5P_HDMI_CMIN S5P_HDMI_BASE(0x006C)
#define S5P_H_BLANK_0 S5P_HDMI_BASE(0x00A0)
#define S5P_H_BLANK_1 S5P_HDMI_BASE(0x00A4)
#define S5P_V_BLANK_0 S5P_HDMI_BASE(0x00B0)
#define S5P_V_BLANK_1 S5P_HDMI_BASE(0x00B4)
#define S5P_V_BLANK_2 S5P_HDMI_BASE(0x00B8)
#define S5P_H_V_LINE_0 S5P_HDMI_BASE(0x00C0)
#define S5P_H_V_LINE_1 S5P_HDMI_BASE(0x00C4)
#define S5P_H_V_LINE_2 S5P_HDMI_BASE(0x00C8)
#define S5P_SYNC_MODE S5P_HDMI_BASE(0x00E4)
#define S5P_INT_PRO_MODE S5P_HDMI_BASE(0x00E8)
#define S5P_V_BLANK_F_0 S5P_HDMI_BASE(0x0110)
#define S5P_V_BLANK_F_1 S5P_HDMI_BASE(0x0114)
#define S5P_V_BLANK_F_2 S5P_HDMI_BASE(0x0118)
#define S5P_H_SYNC_GEN_0 S5P_HDMI_BASE(0x0120)
#define S5P_H_SYNC_GEN_1 S5P_HDMI_BASE(0x0124)
#define S5P_H_SYNC_GEN_2 S5P_HDMI_BASE(0x0128)
#define S5P_V_SYNC_GEN_1_0 S5P_HDMI_BASE(0x0130)
#define S5P_V_SYNC_GEN_1_1 S5P_HDMI_BASE(0x0134)
#define S5P_V_SYNC_GEN_1_2 S5P_HDMI_BASE(0x0138)
#define S5P_V_SYNC_GEN_2_0 S5P_HDMI_BASE(0x0140)
#define S5P_V_SYNC_GEN_2_1 S5P_HDMI_BASE(0x0144)
#define S5P_V_SYNC_GEN_2_2 S5P_HDMI_BASE(0x0148)
#define S5P_V_SYNC_GEN_3_0 S5P_HDMI_BASE(0x0150)
#define S5P_V_SYNC_GEN_3_1 S5P_HDMI_BASE(0x0154)
#define S5P_V_SYNC_GEN_3_2 S5P_HDMI_BASE(0x0158)
#define S5P_ASP_CON S5P_HDMI_BASE(0x0160)
#define S5P_ASP_SP_FLAT S5P_HDMI_BASE(0x0164)
#define S5P_ASP_CHCFG0 S5P_HDMI_BASE(0x0170)
#define S5P_ASP_CHCFG1 S5P_HDMI_BASE(0x0174)
#define S5P_ASP_CHCFG2 S5P_HDMI_BASE(0x0178)
#define S5P_ASP_CHCFG3 S5P_HDMI_BASE(0x017C)
#define S5P_ACR_CON S5P_HDMI_BASE(0x0180)
#define S5P_ACR_MCTS0 S5P_HDMI_BASE(0x0184)
#define S5P_ACR_MCTS1 S5P_HDMI_BASE(0x0188)
#define S5P_ACR_MCTS2 S5P_HDMI_BASE(0x018C)
#define S5P_ACR_CTS0 S5P_HDMI_BASE(0x0190)
#define S5P_ACR_CTS1 S5P_HDMI_BASE(0x0194)
#define S5P_ACR_CTS2 S5P_HDMI_BASE(0x0198)
#define S5P_ACR_N0 S5P_HDMI_BASE(0x01A0)
#define S5P_ACR_N1 S5P_HDMI_BASE(0x01A4)
#define S5P_ACR_N2 S5P_HDMI_BASE(0x01A8)
#define S5P_ACR_LSB2 S5P_HDMI_BASE(0x01B0)
#define S5P_ACR_TXCNT S5P_HDMI_BASE(0x01B4)
#define S5P_ACR_TXINTERVAL S5P_HDMI_BASE(0x01B8)
#define S5P_ACR_CTS_OFFSET S5P_HDMI_BASE(0x01BC)
#define S5P_GCP_CON S5P_HDMI_BASE(0x01C0)
#define S5P_GCP_BYTE1 S5P_HDMI_BASE(0x01D0)
#define S5P_GCP_BYTE2 S5P_HDMI_BASE(0x01D4)
#define S5P_GCP_BYTE3 S5P_HDMI_BASE(0x01D8)
#define S5P_ACP_CON S5P_HDMI_BASE(0x01E0)
#define S5P_ACP_TYPE S5P_HDMI_BASE(0x01E4)
#define S5P_ACP_DATA0 S5P_HDMI_BASE(0x0200)
#define S5P_ACP_DATA1 S5P_HDMI_BASE(0x0204)
#define S5P_ACP_DATA2 S5P_HDMI_BASE(0x0208)
#define S5P_ACP_DATA3 S5P_HDMI_BASE(0x020c)
#define S5P_ACP_DATA4 S5P_HDMI_BASE(0x0210)
#define S5P_ACP_DATA5 S5P_HDMI_BASE(0x0214)
#define S5P_ACP_DATA6 S5P_HDMI_BASE(0x0218)
#define S5P_ACP_DATA7 S5P_HDMI_BASE(0x021c)
#define S5P_ACP_DATA8 S5P_HDMI_BASE(0x0220)
#define S5P_ACP_DATA9 S5P_HDMI_BASE(0x0224)
#define S5P_ACP_DATA10 S5P_HDMI_BASE(0x0228)
#define S5P_ACP_DATA11 S5P_HDMI_BASE(0x022c)
#define S5P_ACP_DATA12 S5P_HDMI_BASE(0x0230)
#define S5P_ACP_DATA13 S5P_HDMI_BASE(0x0234)
#define S5P_ACP_DATA14 S5P_HDMI_BASE(0x0238)
#define S5P_ACP_DATA15 S5P_HDMI_BASE(0x023c)
#define S5P_ACP_DATA16 S5P_HDMI_BASE(0x0240)
#define S5P_ISRC_CON S5P_HDMI_BASE(0x0250)
#define S5P_ISRC1_HEADER1 S5P_HDMI_BASE(0x0264)
#define S5P_ISRC1_DATA0 S5P_HDMI_BASE(0x0270)
#define S5P_ISRC1_DATA1 S5P_HDMI_BASE(0x0274)
#define S5P_ISRC1_DATA2 S5P_HDMI_BASE(0x0278)
#define S5P_ISRC1_DATA3 S5P_HDMI_BASE(0x027c)
#define S5P_ISRC1_DATA4 S5P_HDMI_BASE(0x0280)
#define S5P_ISRC1_DATA5 S5P_HDMI_BASE(0x0284)
#define S5P_ISRC1_DATA6 S5P_HDMI_BASE(0x0288)
#define S5P_ISRC1_DATA7 S5P_HDMI_BASE(0x028c)
#define S5P_ISRC1_DATA8 S5P_HDMI_BASE(0x0290)
#define S5P_ISRC1_DATA9 S5P_HDMI_BASE(0x0294)
#define S5P_ISRC1_DATA10 S5P_HDMI_BASE(0x0298)
#define S5P_ISRC1_DATA11 S5P_HDMI_BASE(0x029c)
#define S5P_ISRC1_DATA12 S5P_HDMI_BASE(0x02a0)
#define S5P_ISRC1_DATA13 S5P_HDMI_BASE(0x02a4)
#define S5P_ISRC1_DATA14 S5P_HDMI_BASE(0x02a8)
#define S5P_ISRC1_DATA15 S5P_HDMI_BASE(0x02ac)
#define S5P_ISRC2_DATA0 S5P_HDMI_BASE(0x02b0)
#define S5P_ISRC2_DATA1 S5P_HDMI_BASE(0x02b4)
#define S5P_ISRC2_DATA2 S5P_HDMI_BASE(0x02b8)
#define S5P_ISRC2_DATA3 S5P_HDMI_BASE(0x02bc)
#define S5P_ISRC2_DATA4 S5P_HDMI_BASE(0x02c0)
#define S5P_ISRC2_DATA5 S5P_HDMI_BASE(0x02c4)
#define S5P_ISRC2_DATA6 S5P_HDMI_BASE(0x02c8)
#define S5P_ISRC2_DATA7 S5P_HDMI_BASE(0x02cc)
#define S5P_ISRC2_DATA8 S5P_HDMI_BASE(0x02d0)
#define S5P_ISRC2_DATA9 S5P_HDMI_BASE(0x02d4)
#define S5P_ISRC2_DATA10 S5P_HDMI_BASE(0x02d8)
#define S5P_ISRC2_DATA11 S5P_HDMI_BASE(0x02dc)
#define S5P_ISRC2_DATA12 S5P_HDMI_BASE(0x02e0)
#define S5P_ISRC2_DATA13 S5P_HDMI_BASE(0x02e4)
#define S5P_ISRC2_DATA14 S5P_HDMI_BASE(0x02e8)
#define S5P_ISRC2_DATA15 S5P_HDMI_BASE(0x02ec)
#define S5P_AVI_CON S5P_HDMI_BASE(0x0300)
#define S5P_AVI_CHECK_SUM S5P_HDMI_BASE(0x0310)
#define S5P_AVI_BYTE1 S5P_HDMI_BASE(0x0320)
#define S5P_AVI_BYTE2 S5P_HDMI_BASE(0x0324)
#define S5P_AVI_BYTE3 S5P_HDMI_BASE(0x0328)
#define S5P_AVI_BYTE4 S5P_HDMI_BASE(0x032c)
#define S5P_AVI_BYTE5 S5P_HDMI_BASE(0x0330)
#define S5P_AVI_BYTE6 S5P_HDMI_BASE(0x0334)
#define S5P_AVI_BYTE7 S5P_HDMI_BASE(0x0338)
#define S5P_AVI_BYTE8 S5P_HDMI_BASE(0x033c)
#define S5P_AVI_BYTE9 S5P_HDMI_BASE(0x0340)
#define S5P_AVI_BYTE10 S5P_HDMI_BASE(0x0344)
#define S5P_AVI_BYTE11 S5P_HDMI_BASE(0x0348)
#define S5P_AVI_BYTE12 S5P_HDMI_BASE(0x034c)
#define S5P_AVI_BYTE13 S5P_HDMI_BASE(0x0350)
#define S5P_AUI_CON S5P_HDMI_BASE(0x0360)
#define S5P_AUI_CHECK_SUM S5P_HDMI_BASE(0x0370)
#define S5P_AUI_BYTE1 S5P_HDMI_BASE(0x0380)
#define S5P_AUI_BYTE2 S5P_HDMI_BASE(0x0384)
#define S5P_AUI_BYTE3 S5P_HDMI_BASE(0x0388)
#define S5P_AUI_BYTE4 S5P_HDMI_BASE(0x038c)
#define S5P_AUI_BYTE5 S5P_HDMI_BASE(0x0390)
#define S5P_MPG_CON S5P_HDMI_BASE(0x03A0)
#define S5P_MPG_CHECK_SUM S5P_HDMI_BASE(0x03B0)
#define S5P_MPEG_BYTE1 S5P_HDMI_BASE(0x03c0)
#define S5P_MPEG_BYTE2 S5P_HDMI_BASE(0x03c4)
#define S5P_MPEG_BYTE3 S5P_HDMI_BASE(0x03c8)
#define S5P_MPEG_BYTE4 S5P_HDMI_BASE(0x03cc)
#define S5P_MPEG_BYTE5 S5P_HDMI_BASE(0x03d0)
#define S5P_SPD_CON S5P_HDMI_BASE(0x0400)
#define S5P_SPD_HEADER0 S5P_HDMI_BASE(0x0410)
#define S5P_SPD_HEADER1 S5P_HDMI_BASE(0x0414)
#define S5P_SPD_HEADER2 S5P_HDMI_BASE(0x0418)
#define S5P_SPD_DATA0 S5P_HDMI_BASE(0x0420)
#define S5P_SPD_DATA1 S5P_HDMI_BASE(0x0424)
#define S5P_SPD_DATA2 S5P_HDMI_BASE(0x0428)
#define S5P_SPD_DATA3 S5P_HDMI_BASE(0x042c)
#define S5P_SPD_DATA4 S5P_HDMI_BASE(0x0430)
#define S5P_SPD_DATA5 S5P_HDMI_BASE(0x0434)
#define S5P_SPD_DATA6 S5P_HDMI_BASE(0x0438)
#define S5P_SPD_DATA7 S5P_HDMI_BASE(0x043c)
#define S5P_SPD_DATA8 S5P_HDMI_BASE(0x0440)
#define S5P_SPD_DATA9 S5P_HDMI_BASE(0x0444)
#define S5P_SPD_DATA10 S5P_HDMI_BASE(0x0448)
#define S5P_SPD_DATA11 S5P_HDMI_BASE(0x044c)
#define S5P_SPD_DATA12 S5P_HDMI_BASE(0x0450)
#define S5P_SPD_DATA13 S5P_HDMI_BASE(0x0454)
#define S5P_SPD_DATA14 S5P_HDMI_BASE(0x0458)
#define S5P_SPD_DATA15 S5P_HDMI_BASE(0x045c)
#define S5P_SPD_DATA16 S5P_HDMI_BASE(0x0460)
#define S5P_SPD_DATA17 S5P_HDMI_BASE(0x0464)
#define S5P_SPD_DATA18 S5P_HDMI_BASE(0x0468)
#define S5P_SPD_DATA19 S5P_HDMI_BASE(0x046c)
#define S5P_SPD_DATA20 S5P_HDMI_BASE(0x0470)
#define S5P_SPD_DATA21 S5P_HDMI_BASE(0x0474)
#define S5P_SPD_DATA22 S5P_HDMI_BASE(0x0478)
#define S5P_SPD_DATA23 S5P_HDMI_BASE(0x048c)
#define S5P_SPD_DATA24 S5P_HDMI_BASE(0x0480)
#define S5P_SPD_DATA25 S5P_HDMI_BASE(0x0484)
#define S5P_SPD_DATA26 S5P_HDMI_BASE(0x0488)
#define S5P_SPD_DATA27 S5P_HDMI_BASE(0x048c)
#define S5P_HDCP_RX_SHA1_0_0 S5P_HDMI_BASE(0x0600)
#define S5P_HDCP_RX_SHA1_0_1 S5P_HDMI_BASE(0x0604)
#define S5P_HDCP_RX_SHA1_0_2 S5P_HDMI_BASE(0x0608)
#define S5P_HDCP_RX_SHA1_0_3 S5P_HDMI_BASE(0x060C)
#define S5P_HDCP_RX_SHA1_1_0 S5P_HDMI_BASE(0x0610)
#define S5P_HDCP_RX_SHA1_1_1 S5P_HDMI_BASE(0x0614)
#define S5P_HDCP_RX_SHA1_1_2 S5P_HDMI_BASE(0x0618)
#define S5P_HDCP_RX_SHA1_1_3 S5P_HDMI_BASE(0x061C)
#define S5P_HDCP_RX_SHA1_2_0 S5P_HDMI_BASE(0x0620)
#define S5P_HDCP_RX_SHA1_2_1 S5P_HDMI_BASE(0x0624)
#define S5P_HDCP_RX_SHA1_2_2 S5P_HDMI_BASE(0x0628)
#define S5P_HDCP_RX_SHA1_2_3 S5P_HDMI_BASE(0x062C)
#define S5P_HDCP_RX_SHA1_3_0 S5P_HDMI_BASE(0x0630)
#define S5P_HDCP_RX_SHA1_3_1 S5P_HDMI_BASE(0x0634)
#define S5P_HDCP_RX_SHA1_3_2 S5P_HDMI_BASE(0x0638)
#define S5P_HDCP_RX_SHA1_3_3 S5P_HDMI_BASE(0x063C)
#define S5P_HDCP_RX_SHA1_4_0 S5P_HDMI_BASE(0x0640)
#define S5P_HDCP_RX_SHA1_4_1 S5P_HDMI_BASE(0x0644)
#define S5P_HDCP_RX_SHA1_4_2 S5P_HDMI_BASE(0x0648)
#define S5P_HDCP_RX_SHA1_4_3 S5P_HDMI_BASE(0x064C)
#define S5P_HDCP_RX_KSV_0_0 S5P_HDMI_BASE(0x0650)
#define S5P_HDCP_RX_KSV_0_1 S5P_HDMI_BASE(0x0654)
#define S5P_HDCP_RX_KSV_0_2 S5P_HDMI_BASE(0x0658)
#define S5P_HDCP_RX_KSV_0_3 S5P_HDMI_BASE(0x065C)
#define S5P_HDCP_RX_KSV_0_4 S5P_HDMI_BASE(0x0660)
#define S5P_HDCP_RX_KSV_LIST_CTRL S5P_HDMI_BASE(0x0664)
#define S5P_HDCP_AUTH_STATUS S5P_HDMI_BASE(0x0670)
#define S5P_HDCP_CTRL1 S5P_HDMI_BASE(0x0680)
#define S5P_HDCP_CTRL2 S5P_HDMI_BASE(0x0684)
#define S5P_HDCP_CHECK_RESULT S5P_HDMI_BASE(0x0690)
#define S5P_HDCP_BKSV_0_0 S5P_HDMI_BASE(0x06A0)
#define S5P_HDCP_BKSV_0_1 S5P_HDMI_BASE(0x06A4)
#define S5P_HDCP_BKSV_0_2 S5P_HDMI_BASE(0x06A8)
#define S5P_HDCP_BKSV_0_3 S5P_HDMI_BASE(0x06AC)
#define S5P_HDCP_BKSV_1 S5P_HDMI_BASE(0x06B0)
#define S5P_HDCP_AKSV_0_0 S5P_HDMI_BASE(0x06C0)
#define S5P_HDCP_AKSV_0_1 S5P_HDMI_BASE(0x06C4)
#define S5P_HDCP_AKSV_0_2 S5P_HDMI_BASE(0x06C8)
#define S5P_HDCP_AKSV_0_3 S5P_HDMI_BASE(0x06CC)
#define S5P_HDCP_AKSV_1 S5P_HDMI_BASE(0x06D0)
#define S5P_HDCP_An_0_0 S5P_HDMI_BASE(0x06E0)
#define S5P_HDCP_An_0_1 S5P_HDMI_BASE(0x06E4)
#define S5P_HDCP_An_0_2 S5P_HDMI_BASE(0x06E8)
#define S5P_HDCP_An_0_3 S5P_HDMI_BASE(0x06EC)
#define S5P_HDCP_An_1_0 S5P_HDMI_BASE(0x06F0)
#define S5P_HDCP_An_1_1 S5P_HDMI_BASE(0x06F4)
#define S5P_HDCP_An_1_2 S5P_HDMI_BASE(0x06F8)
#define S5P_HDCP_An_1_3 S5P_HDMI_BASE(0x06FC)
#define S5P_HDCP_BCAPS S5P_HDMI_BASE(0x0700)
#define S5P_HDCP_BSTATUS_0 S5P_HDMI_BASE(0x0710)
#define S5P_HDCP_BSTATUS_1 S5P_HDMI_BASE(0x0714)
#define S5P_HDCP_Ri_0 S5P_HDMI_BASE(0x0740)
#define S5P_HDCP_Ri_1 S5P_HDMI_BASE(0x0744)
#define S5P_HDCP_I2C_INT S5P_HDMI_BASE(0x0780)
#define S5P_HDCP_AN_INT S5P_HDMI_BASE(0x0790)
#define S5P_HDCP_WDT_INT S5P_HDMI_BASE(0x07a0)
#define S5P_HDCP_RI_INT S5P_HDMI_BASE(0x07b0)
#define S5P_HDCP_RI_COMPARE_0 S5P_HDMI_BASE(0x07d0)
#define S5P_HDCP_RI_COMPARE_1 S5P_HDMI_BASE(0x07d4)
#define S5P_HDCP_FRAME_COUNT S5P_HDMI_BASE(0x07e0)
#define HDMI_GAMUT_CON S5P_HDMI_BASE(0x0500)
#define HDMI_GAMUT_HEADER0 S5P_HDMI_BASE(0x0504)
#define HDMI_GAMUT_HEADER1 S5P_HDMI_BASE(0x0508)
#define HDMI_GAMUT_HEADER2 S5P_HDMI_BASE(0x050c)
#define HDMI_GAMUT_DATA00 S5P_HDMI_BASE(0x0510)
#define HDMI_GAMUT_DATA01 S5P_HDMI_BASE(0x0514)
#define HDMI_GAMUT_DATA02 S5P_HDMI_BASE(0x0518)
#define HDMI_GAMUT_DATA03 S5P_HDMI_BASE(0x051c)
#define HDMI_GAMUT_DATA04 S5P_HDMI_BASE(0x0520)
#define HDMI_GAMUT_DATA05 S5P_HDMI_BASE(0x0524)
#define HDMI_GAMUT_DATA06 S5P_HDMI_BASE(0x0528)
#define HDMI_GAMUT_DATA07 S5P_HDMI_BASE(0x052c)
#define HDMI_GAMUT_DATA08 S5P_HDMI_BASE(0x0530)
#define HDMI_GAMUT_DATA09 S5P_HDMI_BASE(0x0534)
#define HDMI_GAMUT_DATA10 S5P_HDMI_BASE(0x0538)
#define HDMI_GAMUT_DATA11 S5P_HDMI_BASE(0x053c)
#define HDMI_GAMUT_DATA12 S5P_HDMI_BASE(0x0540)
#define HDMI_GAMUT_DATA13 S5P_HDMI_BASE(0x0544)
#define HDMI_GAMUT_DATA14 S5P_HDMI_BASE(0x0548)
#define HDMI_GAMUT_DATA15 S5P_HDMI_BASE(0x054c)
#define HDMI_GAMUT_DATA16 S5P_HDMI_BASE(0x0550)
#define HDMI_GAMUT_DATA17 S5P_HDMI_BASE(0x0554)
#define HDMI_GAMUT_DATA18 S5P_HDMI_BASE(0x0558)
#define HDMI_GAMUT_DATA19 S5P_HDMI_BASE(0x055c)
#define HDMI_GAMUT_DATA20 S5P_HDMI_BASE(0x0560)
#define HDMI_GAMUT_DATA21 S5P_HDMI_BASE(0x0564)
#define HDMI_GAMUT_DATA22 S5P_HDMI_BASE(0x0568)
#define HDMI_GAMUT_DATA23 S5P_HDMI_BASE(0x056c)
#define HDMI_GAMUT_DATA24 S5P_HDMI_BASE(0x0570)
#define HDMI_GAMUT_DATA25 S5P_HDMI_BASE(0x0574)
#define HDMI_GAMUT_DATA26 S5P_HDMI_BASE(0x0578)
#define HDMI_GAMUT_DATA27 S5P_HDMI_BASE(0x057c)
#define S5P_HDMI_DC_CONTROL S5P_HDMI_BASE(0x05C0)
#define S5P_HDMI_VIDEO_PATTERN_GEN S5P_HDMI_BASE(0x05C4)
#define S5P_HDMI_HPD_GEN S5P_HDMI_BASE(0x05C8)
#define S5P_TG_CMD S5P_HDMI_TG_BASE(0x0000)
#define S5P_TG_H_FSZ_L S5P_HDMI_TG_BASE(0x0018)
#define S5P_TG_H_FSZ_H S5P_HDMI_TG_BASE(0x001C)
#define S5P_TG_HACT_ST_L S5P_HDMI_TG_BASE(0x0020)
#define S5P_TG_HACT_ST_H S5P_HDMI_TG_BASE(0x0024)
#define S5P_TG_HACT_SZ_L S5P_HDMI_TG_BASE(0x0028)
#define S5P_TG_HACT_SZ_H S5P_HDMI_TG_BASE(0x002C)
#define S5P_TG_V_FSZ_L S5P_HDMI_TG_BASE(0x0030)
#define S5P_TG_V_FSZ_H S5P_HDMI_TG_BASE(0x0034)
#define S5P_TG_VSYNC_L S5P_HDMI_TG_BASE(0x0038)
#define S5P_TG_VSYNC_H S5P_HDMI_TG_BASE(0x003C)
#define S5P_TG_VSYNC2_L S5P_HDMI_TG_BASE(0x0040)
#define S5P_TG_VSYNC2_H S5P_HDMI_TG_BASE(0x0044)
#define S5P_TG_VACT_ST_L S5P_HDMI_TG_BASE(0x0048)
#define S5P_TG_VACT_ST_H S5P_HDMI_TG_BASE(0x004C)
#define S5P_TG_VACT_SZ_L S5P_HDMI_TG_BASE(0x0050)
#define S5P_TG_VACT_SZ_H S5P_HDMI_TG_BASE(0x0054)
#define S5P_TG_FIELD_CHG_L S5P_HDMI_TG_BASE(0x0058)
#define S5P_TG_FIELD_CHG_H S5P_HDMI_TG_BASE(0x005C)
#define S5P_TG_VACT_ST2_L S5P_HDMI_TG_BASE(0x0060)
#define S5P_TG_VACT_ST2_H S5P_HDMI_TG_BASE(0x0064)
#define S5P_TG_VSYNC_TOP_HDMI_L S5P_HDMI_TG_BASE(0x0078)
#define S5P_TG_VSYNC_TOP_HDMI_H S5P_HDMI_TG_BASE(0x007C)
#define S5P_TG_VSYNC_BOT_HDMI_L S5P_HDMI_TG_BASE(0x0080)
#define S5P_TG_VSYNC_BOT_HDMI_H S5P_HDMI_TG_BASE(0x0084)
#define S5P_TG_FIELD_TOP_HDMI_L S5P_HDMI_TG_BASE(0x0088)
#define S5P_TG_FIELD_TOP_HDMI_H S5P_HDMI_TG_BASE(0x008C)
#define S5P_TG_FIELD_BOT_HDMI_L S5P_HDMI_TG_BASE(0x0090)
#define S5P_TG_FIELD_BOT_HDMI_H S5P_HDMI_TG_BASE(0x0094)
#define S5P_EFUSE_CTRL S5P_HDMI_EFUSE_BASE(0x0000)
#define S5P_EFUSE_STATUS S5P_HDMI_EFUSE_BASE(0x0004)
#define S5P_EFUSE_ADDR_WIDTH S5P_HDMI_EFUSE_BASE(0x0008)
#define S5P_EFUSE_SIGDEV_ASSERT S5P_HDMI_EFUSE_BASE(0x000c)
#define S5P_EFUSE_SIGDEV_DEASSERT S5P_HDMI_EFUSE_BASE(0x0010)
#define S5P_EFUSE_PRCHG_ASSERT S5P_HDMI_EFUSE_BASE(0x0014)
#define S5P_EFUSE_PRCHG_DEASSERT S5P_HDMI_EFUSE_BASE(0x0018)
#define S5P_EFUSE_FSET_ASSERT S5P_HDMI_EFUSE_BASE(0x001c)
#define S5P_EFUSE_FSET_DEASSERT S5P_HDMI_EFUSE_BASE(0x0020)
#define S5P_EFUSE_SENSING S5P_HDMI_EFUSE_BASE(0x0024)
#define S5P_EFUSE_SCK_ASSERT S5P_HDMI_EFUSE_BASE(0x0028)
#define S5P_EFUSE_SCK_DEASSERT S5P_HDMI_EFUSE_BASE(0x002c)
#define S5P_EFUSE_SDOUT_OFFSET S5P_HDMI_EFUSE_BASE(0x0030)
#define S5P_EFUSE_READ_OFFSET S5P_HDMI_EFUSE_BASE(0x0034)
#define S5P_HDMI_I2S_CLK_CON S5P_HDMI_I2S_BASE(0x0000)
#define S5P_HDMI_I2S_CON_1 S5P_HDMI_I2S_BASE(0x0004)
#define S5P_HDMI_I2S_CON_2 S5P_HDMI_I2S_BASE(0x0008)
#define S5P_HDMI_I2S_PIN_SEL_0 S5P_HDMI_I2S_BASE(0x000C)
#define S5P_HDMI_I2S_PIN_SEL_1 S5P_HDMI_I2S_BASE(0x0010)
#define S5P_HDMI_I2S_PIN_SEL_2 S5P_HDMI_I2S_BASE(0x0014)
#define S5P_HDMI_I2S_PIN_SEL_3 S5P_HDMI_I2S_BASE(0x0018)
#define S5P_HDMI_I2S_DSD_CON S5P_HDMI_I2S_BASE(0x001C)
#define S5P_HDMI_I2S_MUX_CON S5P_HDMI_I2S_BASE(0x0020)
#define S5P_HDMI_I2S_CH_ST_CON S5P_HDMI_I2S_BASE(0x0024)
#define S5P_HDMI_I2S_CH_ST_0 S5P_HDMI_I2S_BASE(0x0028)
#define S5P_HDMI_I2S_CH_ST_1 S5P_HDMI_I2S_BASE(0x002C)
#define S5P_HDMI_I2S_CH_ST_2 S5P_HDMI_I2S_BASE(0x0030)
#define S5P_HDMI_I2S_CH_ST_3 S5P_HDMI_I2S_BASE(0x0034)
#define S5P_HDMI_I2S_CH_ST_4 S5P_HDMI_I2S_BASE(0x0038)
#define S5P_HDMI_I2S_CH_ST_SH_0 S5P_HDMI_I2S_BASE(0x003C)
#define S5P_HDMI_I2S_CH_ST_SH_1 S5P_HDMI_I2S_BASE(0x0040)
#define S5P_HDMI_I2S_CH_ST_SH_2 S5P_HDMI_I2S_BASE(0x0044)
#define S5P_HDMI_I2S_CH_ST_SH_3 S5P_HDMI_I2S_BASE(0x0048)
#define S5P_HDMI_I2S_CH_ST_SH_4 S5P_HDMI_I2S_BASE(0x004C)
#define S5P_HDMI_I2S_VD_DATA S5P_HDMI_I2S_BASE(0x0050)
#define S5P_HDMI_I2S_MUX_CH S5P_HDMI_I2S_BASE(0x0054)
#define S5P_HDMI_I2S_MUX_CUV S5P_HDMI_I2S_BASE(0x0058)
#define S5P_HDMI_I2S_IRQ_MASK S5P_HDMI_I2S_BASE(0x005C)
#define S5P_HDMI_I2S_IRQ_STATUS S5P_HDMI_I2S_BASE(0x0060)
#define S5P_HDMI_I2S_CH0_L_0 S5P_HDMI_I2S_BASE(0x0064)
#define S5P_HDMI_I2S_CH0_L_1 S5P_HDMI_I2S_BASE(0x0068)
#define S5P_HDMI_I2S_CH0_L_2 S5P_HDMI_I2S_BASE(0x006C)
#define S5P_HDMI_I2S_CH0_L_3 S5P_HDMI_I2S_BASE(0x0070)
#define S5P_HDMI_I2S_CH0_R_0 S5P_HDMI_I2S_BASE(0x0074)
#define S5P_HDMI_I2S_CH0_R_1 S5P_HDMI_I2S_BASE(0x0078)
#define S5P_HDMI_I2S_CH0_R_2 S5P_HDMI_I2S_BASE(0x007C)
#define S5P_HDMI_I2S_CH0_R_3 S5P_HDMI_I2S_BASE(0x0080)
#define S5P_HDMI_I2S_CH1_L_0 S5P_HDMI_I2S_BASE(0x0084)
#define S5P_HDMI_I2S_CH1_L_1 S5P_HDMI_I2S_BASE(0x0088)
#define S5P_HDMI_I2S_CH1_L_2 S5P_HDMI_I2S_BASE(0x008C)
#define S5P_HDMI_I2S_CH1_L_3 S5P_HDMI_I2S_BASE(0x0090)
#define S5P_HDMI_I2S_CH1_R_0 S5P_HDMI_I2S_BASE(0x0094)
#define S5P_HDMI_I2S_CH1_R_1 S5P_HDMI_I2S_BASE(0x0098)
#define S5P_HDMI_I2S_CH1_R_2 S5P_HDMI_I2S_BASE(0x009C)
#define S5P_HDMI_I2S_CH1_R_3 S5P_HDMI_I2S_BASE(0x00A0)
#define S5P_HDMI_I2S_CH2_L_0 S5P_HDMI_I2S_BASE(0x00A4)
#define S5P_HDMI_I2S_CH2_L_1 S5P_HDMI_I2S_BASE(0x00A8)
#define S5P_HDMI_I2S_CH2_L_2 S5P_HDMI_I2S_BASE(0x00AC)
#define S5P_HDMI_I2S_CH2_L_3 S5P_HDMI_I2S_BASE(0x00B0)
#define S5P_HDMI_I2S_CH2_R_0 S5P_HDMI_I2S_BASE(0x00B4)
#define S5P_HDMI_I2S_CH2_R_1 S5P_HDMI_I2S_BASE(0x00B8)
#define S5P_HDMI_I2S_CH2_R_2 S5P_HDMI_I2S_BASE(0x00BC)
#define S5P_HDMI_I2S_Ch2_R_3 S5P_HDMI_I2S_BASE(0x00C0)
#define S5P_HDMI_I2S_CH3_L_0 S5P_HDMI_I2S_BASE(0x00C4)
#define S5P_HDMI_I2S_CH3_L_1 S5P_HDMI_I2S_BASE(0x00C8)
#define S5P_HDMI_I2S_CH3_L_2 S5P_HDMI_I2S_BASE(0x00CC)
#define S5P_HDMI_I2S_CH3_R_0 S5P_HDMI_I2S_BASE(0x00D0)
#define S5P_HDMI_I2S_CH3_R_1 S5P_HDMI_I2S_BASE(0x00D4)
#define S5P_HDMI_I2S_CH3_R_2 S5P_HDMI_I2S_BASE(0x00D8)
#define S5P_HDMI_I2S_CUV_L_R S5P_HDMI_I2S_BASE(0x00DC)
#define S5P_SPDIFIN_CLK_CTRL S5P_HDMI_SPDIF_BASE(0x0000)
#define S5P_SPDIFIN_OP_CTRL S5P_HDMI_SPDIF_BASE(0x0004)
#define S5P_SPDIFIN_IRQ_MASK S5P_HDMI_SPDIF_BASE(0x0008)
#define S5P_SPDIFIN_IRQ_STATUS S5P_HDMI_SPDIF_BASE(0x000C)
#define S5P_SPDIFIN_CONFIG_1 S5P_HDMI_SPDIF_BASE(0x0010)
#define S5P_SPDIFIN_CONFIG_2 S5P_HDMI_SPDIF_BASE(0x0014)
#define S5P_SPDIFIN_USER_VALUE_1 S5P_HDMI_SPDIF_BASE(0x0020)
#define S5P_SPDIFIN_USER_VALUE_2 S5P_HDMI_SPDIF_BASE(0x0024)
#define S5P_SPDIFIN_USER_VALUE_3 S5P_HDMI_SPDIF_BASE(0x0028)
#define S5P_SPDIFIN_USER_VALUE_4 S5P_HDMI_SPDIF_BASE(0x002C)
#define S5P_SPDIFIN_CH_STATUS_0_1 S5P_HDMI_SPDIF_BASE(0x0030)
#define S5P_SPDIFIN_CH_STATUS_0_2 S5P_HDMI_SPDIF_BASE(0x0034)
#define S5P_SPDIFIN_CH_STATUS_0_3 S5P_HDMI_SPDIF_BASE(0x0038)
#define S5P_SPDIFIN_CH_STATUS_0_4 S5P_HDMI_SPDIF_BASE(0x003C)
#define S5P_SPDIFIN_CH_STATUS_1 S5P_HDMI_SPDIF_BASE(0x0040)
#define S5P_SPDIFIN_FRAME_PERIOD_1 S5P_HDMI_SPDIF_BASE(0x0048)
#define S5P_SPDIFIN_FRAME_PERIOD_2 S5P_HDMI_SPDIF_BASE(0x004C)
#define S5P_SPDIFIN_Pc_INFO_1 S5P_HDMI_SPDIF_BASE(0x0050)
#define S5P_SPDIFIN_Pc_INFO_2 S5P_HDMI_SPDIF_BASE(0x0054)
#define S5P_SPDIFIN_Pd_INFO_1 S5P_HDMI_SPDIF_BASE(0x0058)
#define S5P_SPDIFIN_Pd_INFO_2 S5P_HDMI_SPDIF_BASE(0x005C)
#define S5P_SPDIFIN_DATA_BUF_0_1 S5P_HDMI_SPDIF_BASE(0x0060)
#define S5P_SPDIFIN_DATA_BUF_0_2 S5P_HDMI_SPDIF_BASE(0x0064)
#define S5P_SPDIFIN_DATA_BUF_0_3 S5P_HDMI_SPDIF_BASE(0x0068)
#define S5P_SPDIFIN_USER_BUF_0 S5P_HDMI_SPDIF_BASE(0x006C)
#define S5P_SPDIFIN_DATA_BUF_1_1 S5P_HDMI_SPDIF_BASE(0x0070)
#define S5P_SPDIFIN_DATA_BUF_1_2 S5P_HDMI_SPDIF_BASE(0x0074)
#define S5P_SPDIFIN_DATA_BUF_1_3 S5P_HDMI_SPDIF_BASE(0x0078)
#define S5P_SPDIFIN_USER_BUF_1 S5P_HDMI_SPDIF_BASE(0x007C)
#define BLUE_SCR_EN (1<<5)
#define BLUE_SCR_DIS (0<<5)
#define ASP_EN (1<<2)
#define ASP_DIS (0<<2)
#define PWDN_ENB_NORMAL (1<<1)
#define PWDN_ENB_PD (0<<1)
#define HDMI_EN (1<<0)
#define HDMI_DIS (~HDMI_EN)
#define PX_LMT_CTRL_BYPASS (0<<5)
#define PX_LMT_CTRL_RGB (1<<5)
#define PX_LMT_CTRL_YPBPR (2<<5)
#define PX_LMT_CTRL_RESERVED (3<<5)
#define VID_PREAMBLE_EN (0<<5)
#define VID_PREAMBLE_DIS (1<<5)
#define GUARD_BAND_EN (0<<1)
#define GUARD_BAND_DIS (1<<1)
#define AUTHEN_ACK_AUTH (1<<7)
#define AUTHEN_ACK_NOT (0<<7)
#define AUD_FIFO_OVF_FULL (1<<6)
#define AUD_FIFO_OVF_NOT (0<<6)
#define UPDATE_RI_INT_OCC (1<<4)
#define UPDATE_RI_INT_NOT (0<<4)
#define UPDATE_RI_INT_CLEAR (1<<4)
#define UPDATE_PJ_INT_OCC (1<<3)
#define UPDATE_PJ_INT_NOT (0<<3)
#define UPDATE_PJ_INT_CLEAR (1<<3)
#define EXCHANGEKSV_INT_OCC (1<<2)
#define EXCHANGEKSV_INT_NOT (0<<2)
#define EXCHANGEKSV_INT_CLEAR (1<<2)
#define WATCHDOG_INT_OCC (1<<1)
#define WATCHDOG_INT_NOT (0<<1)
#define WATCHDOG_INT_CLEAR (1<<1)
#define WTFORACTIVERX_INT_OCC (1)
#define WTFORACTIVERX_INT_NOT (0)
#define WTFORACTIVERX_INT_CLEAR (1)
#define AUD_FIFO_OVF_EN (1<<6)
#define AUD_FIFO_OVF_DIS (0<<6)
#define UPDATE_RI_INT_EN (1<<4)
#define UPDATE_RI_INT_DIS (0<<4)
#define UPDATE_PJ_INT_EN (1<<3)
#define UPDATE_PJ_INT_DIS (0<<3)
#define EXCHANGEKSV_INT_EN (1<<2)
#define EXCHANGEKSV_INT_DIS (0<<2)
#define WATCHDOG_INT_EN (1<<1)
#define WATCHDOG_INT_DIS (0<<1)
#define WTFORACTIVERX_INT_EN (1)
#define WTFORACTIVERX_INT_DIS (0)
#define HDCP_STATUS_EN_ALL (UPDATE_RI_INT_EN|\
UPDATE_PJ_INT_DIS|\
EXCHANGEKSV_INT_EN|\
WATCHDOG_INT_EN|\
WTFORACTIVERX_INT_EN)
#define HDCP_STATUS_DIS_ALL (~0x1f)
#define SW_HPD_PLUGGED (1<<1)
#define SW_HPD_UNPLUGGED (0<<1)
#define HDMI_MODE_EN (1<<1)
#define HDMI_MODE_DIS (0<<1)
#define DVI_MODE_EN (1)
#define DVI_MODE_DIS (0)
#define HDCP_ENC_ENABLE (1)
#define HDCP_ENC_DISABLE (0)
#define SET_BLUESCREEN_0(x) (0xff&(x))
#define SET_BLUESCREEN_1(x) (0xff&(x))
#define SET_BLUESCREEN_2(x) (0xff&(x))
#define SET_HDMI_YMAX(x) (0xff&(x))
#define SET_HDMI_YMIN(x) (0xff&(x))
#define SET_HDMI_CMAX(x) (0xff&(x))
#define SET_HDMI_CMIN(x) (0xff&(x))
#define SET_VBI_ST_MG(x) (0xff&(x))
#define SET_VBI_END_MG(x) (0xff&(x))
#define SET_VACT_ST_MG(x) (0xff&(x))
#define SET_H_BLANK_L(x) (0xff&(x))
#define SET_H_BLANK_H(x) (0x7&((x)>>8))
#define SET_V2_BLANK_L(x) (0xff&(x))
#define SET_V1_BLANK_L(x) ((0x1f&(x))<<3)
#define SET_V2_BLANK_H(x) (0x7&((x)>>8))
#define SET_V1_BLANK_H(x) (0x3f&((x)>>5))
#define SET_V_LINE_L(x) (0xff&(x))
#define SET_H_LINE_L(x) ((0xf&(x))<<4)
#define SET_V_LINE_H(x) (0xf&((x)>>8))
#define SET_H_LINE_H(x) (0xff&((x)>>4))
#define V_SYNC_POL_ACT_LOW (1)
#define V_SYNC_POL_ACT_HIGH (0)
#define INT_PRO_MODE_INTERLACE (1)
#define INT_PRO_MODE_PROGRESSIVE (0)
#define SET_V_BOT_ST_L(x) (0xff&(x))
#define SET_V_BOT_END_L(x) ((0x1f&(x))<<3)
#define SET_V_BOT_ST_H(x) (0x7&((x)>>8))
#define SET_V_BOT_END_H(x) (0x3f&((x)>>5))
#define SET_HSYNC_START_L(x) (0xff&(x))
#define SET_HSYNC_END_L(x) ((0x3f&(x))<<2)
#define SET_HSYNC_START_H(x) (0x3&((x)>>8))
#define SET_HSYNC_POL_ACT_LOW (1<<4)
#define SET_HSYNC_POL_ACT_HIGH (0<<4)
#define SET_HSYNC_END_H(x) (0xf&((x)>>6))
#define SET_VSYNC_T_END_L(x) (0xff&(x))
#define SET_VSYNC_T_ST_L(x) ((0xf&(x))<<4)
#define SET_VSYNC_T_END_H(x) (0xf&((x)>>8))
#define SET_VSYNC_T_ST_H(x) (0xff&((x)>>4))
#define SET_VSYNC_B_END_L(x) (0xff&(x))
#define SET_VSYNC_B_ST_L(x) ((0xf&(x))<<4)
#define SET_VSYNC_B_END_H(x) (0xf&((x)>>8))
#define SET_VSYNC_B_ST_H(x) (0xff&((x)>>4))
#define SET_VSYNC_H_POST_END_L(x) (0xff&(x))
#define SET_VSYNC_H_POST_ST_L(x) ((0xf&(x))<<4)
#define SET_VSYNC_H_POST_END_H(x) (0xf&((x)>>8))
#define SET_VSYNC_H_POST_ST_H(x) (0xff&((x)>>4))
#define SACD_EN (1<<5)
#define SACD_DIS (0<<5)
#define AUD_MODE_MULTI_CH (1<<4)
#define AUD_MODE_2_CH (0<<4)
#define SET_SP_PRE(x) (0xf&(x))
#define SET_SP_FLAT(x) (0xf&(x))
#define SPK3R_SEL_I_PCM0L (0<<27)
#define SPK3R_SEL_I_PCM0R (1<<27)
#define SPK3R_SEL_I_PCM1L (2<<27)
#define SPK3R_SEL_I_PCM1R (3<<27)
#define SPK3R_SEL_I_PCM2L (4<<27)
#define SPK3R_SEL_I_PCM2R (5<<27)
#define SPK3R_SEL_I_PCM3L (6<<27)
#define SPK3R_SEL_I_PCM3R (7<<27)
#define SPK3L_SEL_I_PCM0L (0<<24)
#define SPK3L_SEL_I_PCM0R (1<<24)
#define SPK3L_SEL_I_PCM1L (2<<24)
#define SPK3L_SEL_I_PCM1R (3<<24)
#define SPK3L_SEL_I_PCM2L (4<<24)
#define SPK3L_SEL_I_PCM2R (5<<24)
#define SPK3L_SEL_I_PCM3L (6<<24)
#define SPK3L_SEL_I_PCM3R (7<<24)
#define SPK2R_SEL_I_PCM0L (0<<19)
#define SPK2R_SEL_I_PCM0R (1<<19)
#define SPK2R_SEL_I_PCM1L (2<<19)
#define SPK2R_SEL_I_PCM1R (3<<19)
#define SPK2R_SEL_I_PCM2L (4<<19)
#define SPK2R_SEL_I_PCM2R (5<<19)
#define SPK2R_SEL_I_PCM3L (6<<19)
#define SPK2R_SEL_I_PCM3R (7<<19)
#define SPK2L_SEL_I_PCM0L (0<<16)
#define SPK2L_SEL_I_PCM0R (1<<16)
#define SPK2L_SEL_I_PCM1L (2<<16)
#define SPK2L_SEL_I_PCM1R (3<<16)
#define SPK2L_SEL_I_PCM2L (4<<16)
#define SPK2L_SEL_I_PCM2R (5<<16)
#define SPK2L_SEL_I_PCM3L (6<<16)
#define SPK2L_SEL_I_PCM3R (7<<16)
#define SPK1R_SEL_I_PCM0L (0<<11)
#define SPK1R_SEL_I_PCM0R (1<<11)
#define SPK1R_SEL_I_PCM1L (2<<11)
#define SPK1R_SEL_I_PCM1R (3<<11)
#define SPK1R_SEL_I_PCM2L (4<<11)
#define SPK1R_SEL_I_PCM2R (5<<11)
#define SPK1R_SEL_I_PCM3L (6<<11)
#define SPK1R_SEL_I_PCM3R (7<<11)
#define SPK1L_SEL_I_PCM0L (0<<8)
#define SPK1L_SEL_I_PCM0R (1<<8)
#define SPK1L_SEL_I_PCM1L (2<<8)
#define SPK1L_SEL_I_PCM1R (3<<8)
#define SPK1L_SEL_I_PCM2L (4<<8)
#define SPK1L_SEL_I_PCM2R (5<<8)
#define SPK1L_SEL_I_PCM3L (6<<8)
#define SPK1L_SEL_I_PCM3R (7<<8)
#define SPK0R_SEL_I_PCM0L (0<<3)
#define SPK0R_SEL_I_PCM0R (1<<3)
#define SPK0R_SEL_I_PCM1L (2<<3)
#define SPK0R_SEL_I_PCM1R (3<<3)
#define SPK0R_SEL_I_PCM2L (4<<3)
#define SPK0R_SEL_I_PCM2R (5<<3)
#define SPK0R_SEL_I_PCM3L (6<<3)
#define SPK0R_SEL_I_PCM3R (7<<3)
#define SPK0L_SEL_I_PCM0L (0)
#define SPK0L_SEL_I_PCM0R (1)
#define SPK0L_SEL_I_PCM1L (2)
#define SPK0L_SEL_I_PCM1R (3)
#define SPK0L_SEL_I_PCM2L (4)
#define SPK0L_SEL_I_PCM2R (5)
#define SPK0L_SEL_I_PCM3L (6)
#define SPK0L_SEL_I_PCM3R (7)
#define ALT_CTS_RATE_CTS_1 (0<<3)
#define ALT_CTS_RATE_CTS_11 (1<<3)
#define ALT_CTS_RATE_CTS_21 (2<<3)
#define ALT_CTS_RATE_CTS_31 (3<<3)
#define ACR_TX_MODE_NO_TX (0)
#define ACR_TX_MODE_TX_ONCE (1)
#define ACR_TX_MODE_TXCNT_VBI (2)
#define ACR_TX_MODE_TX_VPC (3)
#define ACR_TX_MODE_MESURE_CTS (4)
#define SET_ACR_MCTS(x) (0xfffff&(x))
#define SET_ACR_CTS(x) (0xfffff&(x))
#define SET_ACR_N(x) (0xfffff&(x))
#define SET_ACR_LSB2(x) (0xff&(x))
#define SET_ACR_TXCNT(x) (0x1f&(x))
#define SET_ACR_TX_INTERNAL(x) (0xff&(x))
#define SET_ACR_CTS_OFFSET(x) (0xff&(x))
#define GCP_CON_NO_TRAN (0)
#define GCP_CON_TRANS_ONCE (1)
#define GCP_CON_TRANS_EVERY_VSYNC (2)
#define SET_GCP_BYTE1(x) (0xff&(x))
#define SET_ACP_FR_RATE(x) ((0x1f&(x))<<3)
#define ACP_CON_NO_TRAN (0)
#define ACP_CON_TRANS_ONCE (1)
#define ACP_CON_TRANS_EVERY_VSYNC (2)
#define SET_ACP_TYPE(x) (0xff&(x))
#define SET_ACP_DATA(x) (0xff&(x))
#define SET_ISRC_FR_RATE(x) ((0x1f&(x))<<3)
#define ISRC_EN (1<<2)
#define ISRC_DIS (0<<2)
#define ISRC_TX_CON_NO_TRANS (0)
#define ISRC_TX_CON_TRANS_ONCE (1)
#define ISRC_TX_CON_TRANS_EVERY_VSYNC (2)
#define SET_ISRC1_HEADER(x) (0xff&(x))
#define SET_ISRC1_DATA(x) (0xff&(x))
#define SET_ISRC2_DATA(x) (0xff&(x))
#define AVI_TX_CON_NO_TRANS (0)
#define AVI_TX_CON_TRANS_ONCE (1)
#define AVI_TX_CON_TRANS_EVERY_VSYNC (2)
#define SET_AVI_CHECK_SUM(x) (0xff&(x))
#define HDMI_CON_PXL_REP_RATIO_MASK (1<<1 | 1<<0)
#define HDMI_DOUBLE_PIXEL_REPETITION (0x01)
#define AVI_PIXEL_REPETITION_DOUBLE (1<<0)
#define AVI_PICTURE_ASPECT_4_3 (1<<4)
#define AVI_PICTURE_ASPECT_16_9 (1<<5)
#define SET_AVI_BYTE(x) (0xff&(x))
#define AUI_TX_CON_NO_TRANS (0)
#define AUI_TX_CON_TRANS_ONCE (1)
#define AUI_TX_CON_TRANS_EVERY_VSYNC (2)
#define SET_AUI_CHECK_SUM(x) (0xff&(x))
#define SET_AUI_BYTE(x) (0xff&(x))
#define MPG_TX_CON_NO_TRANS (0)
#define MPG_TX_CON_TRANS_ONCE (1)
#define MPG_TX_CON_TRANS_EVERY_VSYNC (2)
#define SET_MPG_CHECK_SUM(x) (0xff&(x))
#define SET_MPG_BYTE(x) (0xff&(x))
#define SPD_TX_CON_NO_TRANS (0)
#define SPD_TX_CON_TRANS_ONCE (1)
#define SPD_TX_CON_TRANS_EVERY_VSYNC (2)
#define SET_SPD_HEADER(x) (0xff&(x))
#define SET_SPD_DATA(x) (0xff&(x))
#define OUT_OFFSET_SEL_RGB_FR (0<<4)
#define OUT_OFFSET_SEL_RGB_LR (2<<4)
#define OUT_OFFSET_SEL_YCBCR (3<<4)
#define IN_CLIP_EN (1<<2)
#define IN_CLIP_DIS (0<<2)
#define IN_OFFSET_SEL_RGB_FR (0)
#define IN_OFFSET_SEL_RGB_LR (2)
#define IN_OFFSET_SEL_YCBCR (3)
#define SET_HDMI_CSC_COEF_L(x) (0xff&(x))
#define SET_HDMI_CSC_COEF_H(x) (0x3&((x)>>8))
#define SET_HDMI_SHA1(x) (0xff&(x))
#define GETSYNC_TYPE_EN (1<<4)
#define GETSYNC_TYPE_DIS (~GETSYNC_TYPE_EN)
#define GETSYNC_EN (1<<3)
#define GETSYNC_DIS (~GETSYNC_EN)
#define FIELD_EN (1<<1)
#define FIELD_DIS (~FIELD_EN)
#define TG_EN (1)
#define TG_DIS (~TG_EN)
#define SET_TG_H_FSZ_L(x) (0xff&(x))
#define SET_TG_H_FSZ_H(x) (0x1f&((x)>>8))
#define SET_TG_HACT_ST_L(x) (0xff&(x))
#define SET_TG_HACT_ST_H(x) (0xf&((x)>>8))
#define SET_TG_HACT_SZ_L(x) (0xff&(x))
#define SET_TG_HACT_SZ_H(x) (0xf&((x)>>8))
#define SET_TG_V_FSZ_L(x) (0xff&(x))
#define SET_TG_V_FSZ_H(x) (0x7&((x)>>8))
#define SET_TG_VSYNC_L(x) (0xff&(x))
#define SET_TG_VSYNC_H(x) (0x7&((x)>>8))
#define SET_TG_VSYNC2_L(x) (0xff&(x))
#define SET_TG_VSYNC2_H(x) (0x7&((x)>>8))
#define SET_TG_VACT_ST_L(x) (0xff&(x))
#define SET_TG_VACT_ST_H(x) (0x7&((x)>>8))
#define SET_TG_VACT_SZ_L(x) (0xff&(x))
#define SET_TG_VACT_SZ_H(x) (0x7&((x)>>8))
#define SET_TG_FIELD_CHG_L(x) (0xff&(x))
#define SET_TG_FIELD_CHG_H(x) (0x7&((x)>>8))
#define SET_TG_VACT_ST2_L(x) (0xff&(x))
#define SET_TG_VACT_ST2_H(x) (0x7&((x)>>8))
#define SET_TG_VSYNC_TOP_HDMI_L(x) (0xff&(x))
#define SET_TG_VSYNC_TOP_HDMI_H(x) (0x7&((x)>>8))
#define SET_TG_VSYNC_BOT_HDMI_L(x) (0xff&(x))
#define SET_TG_VSYNC_BOT_HDMI_H(x) (0x7&((x)>>8))
#define SET_TG_FIELD_TOP_HDMI_L(x) (0xff&(x))
#define SET_TG_FIELD_TOP_HDMI_H(x) (0x7&((x)>>8))
#define SET_TG_FIELD_BOT_HDMI_L(x) (0xff&(x))
#define SET_TG_FIELD_BOT_HDMI_H(x) (0x7&((x)>>8))
#define IRQ_WRONG_SIGNAL_ENABLE (1<<0)
#define IRQ_CH_STATUS_RECOVERED_ENABLE (1<<1)
#define IRQ_WRONG_PREAMBLE_ENABLE (1<<2)
#define IRQ_STREAM_HEADER_NOT_DETECTED_ENABLE (1<<3)
#define IRQ_STREAM_HEADER_DETECTED_ENABLE (1<<4)
#define IRQ_STREAM_HEADER_NOT_DETECTED_AT_RIGHTTIME_ENABLE (1<<5)
#define IRQ_ABNORMAL_PD_ENABLE (1<<6)
#define IRQ_BUFFER_OVERFLOW_ENABLE (1<<7)
#define CONFIG_FILTER_3_SAMPLE (0<<6)
#define CONFIG_FILTER_2_SAMPLE (1<<6)
#define CONFIG_LINEAR_PCM_TYPE (0<<5)
#define CONFIG_NON_LINEAR_PCM_TYPE (1<<5)
#define CONFIG_PCPD_AUTO_SET (0<<4)
#define CONFIG_PCPD_MANUAL_SET (1<<4)
#define CONFIG_WORD_LENGTH_AUTO_SET (0<<3)
#define CONFIG_WORD_LENGTH_MANUAL_SET (1<<3)
#define CONFIG_U_V_C_P_NEGLECT (0<<2)
#define CONFIG_U_V_C_P_REPORT (1<<2)
#define CONFIG_BURST_SIZE_1 (0<<1)
#define CONFIG_BURST_SIZE_2 (1<<1)
#define CONFIG_DATA_ALIGN_16BIT (0<<0)
#define CONFIG_DATA_ALIGN_32BIT (1<<0)
#define AUTHEN_ACK_POS 7
#define AUD_FIFO_OVF_POS 6
#define UPDATE_RI_INT_POS 4
#define UPDATE_PJ_INT_POS 3
#define EXCHANGEKSV_INT_POS 2
#define WATCHDOG_INT_POS 1
#define WTFORACTIVERX_INT_POS 0
#define AUTHENTICATED (0x1 << 7)
#define NOT_YET_AUTHENTICATED (0x0 << 7)
#define AUD_FIFO_OVF_INT_OCCURRED (0x1 << 6)
#define AUD_FIFO_OVF_INT_NOT_OCCURRED (0x0 << 6)
#define UPDATE_RI_INT_OCCURRED (0x1 << 4)
#define UPDATE_RI_INT_NOT_OCCURRED (0x0 << 4)
#define UPDATE_PJ_INT_OCCURRED (0x1 << 3)
#define UPDATE_PJ_INT_NOT_OCCURRED (0x0 << 3)
#define EXCHANGEKSV_INT_OCCURRED (0x1 << 2)
#define EXCHANGEKSV_INT_NOT_OCCURRED (0x0 << 2)
#define WATCHDOG_INT_OCCURRED (0x1 << 1)
#define WATCHDOG_INT_NOT_OCCURRED (0x0 << 1)
#define WTFORACTIVERX_INT_OCCURRED (0x1 << 0)
#define WTFORACTIVERX_INT_NOT_OCCURRED (0x0 << 0)
#define AUD_FIFO_OVF_INT_EN (0x1 << 6)
#define AUD_FIFO_OVF_INT_DIS (0x0 << 6)
#define EFUSE_CTRL_ACTIVATE (1)
#define EFUSE_ADDR_WIDTH (240)
#define EFUSE_SIGDEV_ASSERT (0)
#define EFUSE_SIGDEV_DEASSERT (96)
#define EFUSE_PRCHG_ASSERT (0)
#define EFUSE_PRCHG_DEASSERT (144)
#define EFUSE_FSET_ASSERT (48)
#define EFUSE_FSET_DEASSERT (192)
#define EFUSE_SENSING (240)
#define EFUSE_SCK_ASSERT (48)
#define EFUSE_SCK_DEASSERT (144)
#define EFUSE_SDOUT_OFFSET (192)
#define EFUSE_READ_OFFSET (192)
#define EFUSE_ECC_DONE (1<<0)
#define EFUSE_ECC_BUSY (1<<1)
#define EFUSE_ECC_FAIL (1<<2)
#define EN_PJ_EN (0x1 << 4)
#define EN_PJ_DIS (~EN_PJ_EN)
#define SET_REPEATER_TIMEOUT (0x1 << 2)
#define CLEAR_REPEATER_TIMEOUT (~SET_REPEATER_TIMEOUT)
#define CP_DESIRED_EN (0x1 << 1)
#define CP_DESIRED_DIS (~CP_DESIRED_EN)
#define ENABLE_1_DOT_1_FEATURE_EN (0x1 << 0)
#define ENABLE_1_DOT_1_FEATURE_DIS (~ENABLE_1_DOT_1_FEATURE_EN)
#define Pi_MATCH_RESULT__YES ((0x1<<3) | (0x1<<2))
#define Pi_MATCH_RESULT__NO ((0x1<<3) | (0x0<<2))
#define Ri_MATCH_RESULT__YES ((0x1<<1) | (0x1<<0))
#define Ri_MATCH_RESULT__NO ((0x1<<1) | (0x0<<0))
#define CLEAR_ALL_RESULTS 0x0
#define HDCP_ENC_DIS (0x0 << 0)
#define REPEATER_SET (0x1 << 6)
#define REPEATERP_CLEAR (0x1 << 6)
#define READY_SET (0x1 << 5)
#define READY_CLEAR (0x1 << 5)
#define FAST_SET (0x1 << 4)
#define FAST_CLEAR (0x1 << 4)
#define ONE_DOT_ONE_FEATURES_SET (0x1 << 1)
#define ONE_DOT_ONE_FEATURES_CLEAR (0x1 << 1)
#define FAST_REAUTHENTICATION_SET (0x1 << 0)
#define FAST_REAUTHENTICATION_CLEAR (0x1 << 0)
#define SCRAMBLER_KEY_START_EN (0x1 << 7)
#define SCRAMBLER_KEY_START_DIS (~SCRAMBLER_KEY_START_EN)
#define SCRAMBLER_KEY_DONE (0x1 << 6)
#define SCRAMBLER_KEY_GENERATING (0x0 << 6)
#define HAES_START_EN (0x1 << 0)
#define HAES_DECRYPTION_DONE (0x0 << 0)
#define AN_SIZE 8
#define AKSV_SIZE 5
#define BKSV_SIZE 5
#define HDCPLink_Addr 0x74
#define CABLE_PLUGGED (1<<1)
#define CABLE_UNPLUGGED (0<<1)
#define DDC_Addr 0xA0
#define eDDC_Addr 0x60
#define HDCPLink_Addr 0x74
#define HDCP_Bksv 0x00
#define HDCP_Aksv 0x10
#define HDCP_Ainfo 0x15
#define HDCP_An 0x18
#define HDCP_Ri 0x08
#define HDCP_Bcaps 0x40
#define HDCP_BStatus 0x41
#define HDCP_Pj 0x0a
#define HDCP_KSVFIFO 0x43
#define HDCP_SHA1 0x20
#define HDMI_MODE_HDMI 0
#define HDMI_MODE_DVI 1
#define EDID_SEGMENT_ID 0x60
#define EDID_SEGMENT0 0x00
#define EDID_SEGMENT1 0x01
#define EDID_DEVICE_ID 0xA0
#define EDID_ADDR_START 0x00
#define EDID_ADDR_EXT 0x80
#define EDID_RCOUNT 127
#define EDID_POS_EXTENSION 0x7E
#define EDID_POS_CHECKSUM 0x7F
#define VALID_EDID 0xA5
#define NO_VALID_EDID 0
#define EDID_POS_RBUFFER0 0x00
#define EDID_POS_RBUFFER1 0x80
#define EDID_POS_RBUFFER2 0x100
#define EDID_POS_RBUFFER3 0x180
#define EDID_TIMING_EXT_TAG_ADDR_POS 0x80
#define EDID_TIMING_EXT_REV_NUMBER 0x81
#define EDID_DETAILED_TIMING_OFFSET_POS 0x82
#define EDID_COLOR_SPACE_ADDR 0x83
#define EDID_DATA_BLOCK_ADDRESS 0x84
#define EDID_TIMING_EXT_TAG_VAL 0x02
#define EDID_YCBCR444_CS_MASK 0x20
#define EDID_YCBCR422_CS_MASK 0x10
#define EDID_TAG_CODE_MASK 0xE0
#define EDID_DATA_BLOCK_SIZE_MASK 0x1F
#define EDID_NATIVE_RESOLUTION_MASK 0x80
#define EDID_SHORT_AUD_DEC_TAG 0x20
#define EDID_SHORT_VID_DEC_TAG 0x40
#define EDID_HDMI_VSDB_TAG 0x60
#define EDID_SPEAKER_ALLOCATION_TAG 0x80
#define COLOR_SPACE_RGB 0
#define COLOR_SPACE_YCBCR444 1
#define COLOR_SPACE_YCBCR422 2
#define SHORT_VID_720_480P_4_3_NT 0x01
#define SHORT_VID_720_480P_16_9_NT 0x02
#define SHORT_VID_1280_720P_16_9_NT 0x04
#define SHORT_VID_1920_1080i_16_9_NT 0x08
#define SHORT_VID_720_576P_4_3_PAL 0x10
#define SHORT_VID_720_576P_16_9_PAL 0x20
#define SHORT_VID_1280_720P_16_9_PAL 0x40
#define SHORT_VID_1920_1080i_16_9_PAL 0x80
#define SET_HDMI_RESOLUTION_480P 0x00
#define SET_HDMI_RESOLUTION_720P 0x01
#define SET_HDMI_RESOLUTION_1080i 0x02
#define HDMI_WAIT_TIMEOUT 20
#define AUTHENTICATION_SUCCESS 0
#define AUTHENTICATION_FAILURE 1
#define AUTHENTICATION_FAIL_CNT 2
#define HDCP_MAX_DEVS 128
#define HDCP_KSV_SIZE 5
#define CMD_IIC_ADDRMODE_CHANGE 0xFF
/* IIC Addressing Mode Definition */
#define IIC_ADDRMODE_1 0
#define IIC_ADDRMODE_2 1
#define IIC_ADDRMODE_3 2
#define HDMI_IIC_ADDRMODE IIC_ADDRMODE_1
#define IIC_ACK 0
#define IIC_NOACK 1
#define EDID_POS_ERROR 512
#define R_VAL_RETRY_CNT 5
#define CABLE_INSERT 1
#define CABLE_REMOVE (~CABLE_INSERT)
#define HDMI_PHY_READY (1<<0)
/*
* Color Depth
* CD0, CD1, CD2, CD3
*/
#define GCP_CD_NOT_INDICATED 0
#define GCP_CD_24BPP (1<<2)
#define GCP_CD_30BPP (1<<0 | 1<<2)
#define GCP_CD_36BPP (1<<1 | 1<<2)
#define GCP_CD_48BPP (1<<0 | 1<<1 | 1<<2)
#define GCP_DEFAULT_PHASE 1
/* for DC_CONTRAL */
#define HDMI_DC_CTL_8 0
#define HDMI_DC_CTL_10 (1<<0)
#define HDMI_DC_CTL_12 (1<<1)
#define DO_NOT_TRANSMIT (0)
#define HPD_SW_ENABLE (1<<0)
#define HPD_SW_DISABLE (0)
#define HPD_ON (1<<1)
#define HPD_OFF (0)
#define S5P_GPH1_4_HDMI_CEC (0x4 << 16)
#define S5P_GPH1_4_EXT_INT31_4 (0xf << 16)
#define S5P_GPH1_5_HDMI_HPD (0x4 << 20)
#define S5P_GPH1_5_EXT_INT31_5 (0xf << 20)
#endif /* __ASM_ARCH_REGS_HDMI_H */
|
ArthySundaram/firstrepo
|
arch/arm/mach-s5pv210/include/mach/regs-hdmi.h
|
C
|
gpl-2.0
| 39,629 |
/* Conversion of SESE regions to Polyhedra.
Copyright (C) 2009-2015 Free Software Foundation, Inc.
Contributed by Sebastian Pop <[email protected]>.
This file is part of GCC.
GCC 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, or (at your option)
any later version.
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_GRAPHITE_SESE_TO_POLY_H
#define GCC_GRAPHITE_SESE_TO_POLY_H
void build_poly_scop (scop_p);
#endif
|
evaautomation/gcc-linaro
|
gcc/graphite-sese-to-poly.h
|
C
|
gpl-2.0
| 896 |
#if CHRONOS_PLAYMAKER
using HutongGames.PlayMaker;
namespace Chronos.PlayMaker
{
[ActionCategory("Physics 2d (Chronos)")]
[Tooltip("Tests if a Game Object's Rigid Body 2D is Kinematic.")]
public class IsKinematic2d : ChronosComponentAction<Timeline>
{
[RequiredField]
[CheckForComponent(typeof(Timeline))]
public FsmOwnerDefault gameObject;
public FsmEvent trueEvent;
public FsmEvent falseEvent;
[UIHint(UIHint.Variable)]
public FsmBool store;
public bool everyFrame;
public override void Reset()
{
gameObject = null;
trueEvent = null;
falseEvent = null;
store = null;
everyFrame = false;
}
public override void OnEnter()
{
DoIsKinematic();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoIsKinematic();
}
private void DoIsKinematic()
{
if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) return;
var isKinematic = timeline.rigidbody2D.isKinematic;
store.Value = isKinematic;
Fsm.Event(isKinematic ? trueEvent : falseEvent);
}
}
}
#endif
|
zach-king/Unity-Games
|
Prometheus/Assets/Imported/Chronos/PlayMaker/Physics 2D/IsKinematic2d.cs
|
C#
|
gpl-2.0
| 1,069 |
/** @file
* @brief Windows-only Enhanced Metafile input and output.
*/
/* Authors:
* Ulf Erikson <[email protected]>
* Jon A. Cruz <[email protected]>
* Abhishek Sharma
*
* Copyright (C) 2006-2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*
* References:
* - How to Create & Play Enhanced Metafiles in Win32
* http://support.microsoft.com/kb/q145999/
* - INFO: Windows Metafile Functions & Aldus Placeable Metafiles
* http://support.microsoft.com/kb/q66949/
* - Metafile Functions
* http://msdn.microsoft.com/library/en-us/gdi/metafile_0whf.asp
* - Metafile Structures
* http://msdn.microsoft.com/library/en-us/gdi/metafile_5hkj.asp
*/
#ifdef WIN32
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "sp-root.h"
#include "sp-path.h"
#include "style.h"
#include "print.h"
#include "extension/system.h"
#include "extension/print.h"
#include "extension/db.h"
#include "extension/output.h"
#include "display/drawing.h"
#include "display/drawing-item.h"
#include "unit-constants.h"
#include "clear-n_.h"
#include "document.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "emf-win32-print.h"
#include "emf-win32-inout.h"
#define PRINT_EMF_WIN32 "org.inkscape.print.emf.win32"
#ifndef PS_JOIN_MASK
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
#endif
#define DPA 0x00A000C9 // TernaryRasterOperation
namespace Inkscape {
namespace Extension {
namespace Internal {
static float device_scale = DEVICESCALE;
static RECTL rc_old;
static bool clipset = false;
EmfWin32::EmfWin32 (void) // The null constructor
{
return;
}
EmfWin32::~EmfWin32 (void) //The destructor
{
return;
}
bool
EmfWin32::check (Inkscape::Extension::Extension * /*module*/)
{
if (NULL == Inkscape::Extension::db.get(PRINT_EMF_WIN32))
return FALSE;
return TRUE;
}
static void
emf_print_document_to_file(SPDocument *doc, gchar const *filename)
{
Inkscape::Extension::Print *mod;
SPPrintContext context;
gchar const *oldconst;
gchar *oldoutput;
unsigned int ret;
doc->ensureUpToDate();
mod = Inkscape::Extension::get_print(PRINT_EMF_WIN32);
oldconst = mod->get_param_string("destination");
oldoutput = g_strdup(oldconst);
mod->set_param_string("destination", filename);
/* Start */
context.module = mod;
/* fixme: This has to go into module constructor somehow */
/* Create new arena */
mod->base = doc->getRoot();
Inkscape::Drawing drawing;
mod->dkey = SPItem::display_key_new(1);
mod->root = mod->base->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY);
drawing.setRoot(mod->root);
/* Print document */
ret = mod->begin(doc);
if (ret) {
g_free(oldoutput);
throw Inkscape::Extension::Output::save_failed();
}
mod->base->invoke_print(&context);
ret = mod->finish();
/* Release arena */
mod->base->invoke_hide(mod->dkey);
mod->base = NULL;
mod->root = NULL; // deleted by invoke_hide
/* end */
mod->set_param_string("destination", oldoutput);
g_free(oldoutput);
return;
}
void
EmfWin32::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
{
Inkscape::Extension::Extension * ext;
ext = Inkscape::Extension::db.get(PRINT_EMF_WIN32);
if (ext == NULL)
return;
bool old_textToPath = ext->get_param_bool("textToPath");
bool new_val = mod->get_param_bool("textToPath");
ext->set_param_bool("textToPath", new_val);
emf_print_document_to_file(doc, filename);
ext->set_param_bool("textToPath", old_textToPath);
return;
}
typedef struct {
int type;
int level;
ENHMETARECORD *lpEMFR;
} EMF_OBJECT, *PEMF_OBJECT;
typedef struct emf_device_context {
struct SPStyle style;
class SPTextStyle tstyle;
bool stroke_set;
bool fill_set;
SIZEL sizeWnd;
SIZEL sizeView;
float PixelsInX, PixelsInY;
float PixelsOutX, PixelsOutY;
POINTL winorg;
POINTL vieworg;
double ScaleInX, ScaleInY;
double ScaleOutX, ScaleOutY;
COLORREF textColor;
bool textColorSet;
DWORD textAlign;
XFORM worldTransform;
POINTL cur;
} EMF_DEVICE_CONTEXT, *PEMF_DEVICE_CONTEXT;
#define EMF_MAX_DC 128
typedef struct emf_callback_data {
Glib::ustring *outsvg;
Glib::ustring *path;
Glib::ustring *outdef;
EMF_DEVICE_CONTEXT dc[EMF_MAX_DC+1]; // FIXME: This should be dynamic..
int level;
double xDPI, yDPI;
bool pathless_stroke;
bool inpath;
float MMX;
float MMY;
float dwInchesX;
float dwInchesY;
unsigned int id;
CHAR *pDesc;
int n_obj;
PEMF_OBJECT emf_obj;
} EMF_CALLBACK_DATA, *PEMF_CALLBACK_DATA;
static void
output_style(PEMF_CALLBACK_DATA d, int iType)
{
// SVGOStringStream tmp_id;
SVGOStringStream tmp_style;
char tmp[1024] = {0};
float fill_rgb[3];
sp_color_get_rgb_floatv( &(d->dc[d->level].style.fill.value.color), fill_rgb );
float stroke_rgb[3];
sp_color_get_rgb_floatv(&(d->dc[d->level].style.stroke.value.color), stroke_rgb);
// tmp_id << "\n\tid=\"" << (d->id++) << "\"";
// *(d->outsvg) += tmp_id.str().c_str();
*(d->outsvg) += "\n\tstyle=\"";
if (iType == EMR_STROKEPATH || !d->dc[d->level].fill_set) {
tmp_style << "fill:none;";
} else {
snprintf(tmp, 1023,
"fill:#%02x%02x%02x;",
SP_COLOR_F_TO_U(fill_rgb[0]),
SP_COLOR_F_TO_U(fill_rgb[1]),
SP_COLOR_F_TO_U(fill_rgb[2]));
tmp_style << tmp;
snprintf(tmp, 1023,
"fill-rule:%s;",
d->dc[d->level].style.fill_rule.value == 0 ? "evenodd" : "nonzero");
tmp_style << tmp;
tmp_style << "fill-opacity:1;";
if (d->dc[d->level].fill_set && d->dc[d->level].stroke_set && d->dc[d->level].style.stroke_width.value == 1 &&
fill_rgb[0]==stroke_rgb[0] && fill_rgb[1]==stroke_rgb[1] && fill_rgb[2]==stroke_rgb[2])
{
d->dc[d->level].stroke_set = false;
}
}
if (iType == EMR_FILLPATH || !d->dc[d->level].stroke_set) {
tmp_style << "stroke:none;";
} else {
snprintf(tmp, 1023,
"stroke:#%02x%02x%02x;",
SP_COLOR_F_TO_U(stroke_rgb[0]),
SP_COLOR_F_TO_U(stroke_rgb[1]),
SP_COLOR_F_TO_U(stroke_rgb[2]));
tmp_style << tmp;
tmp_style << "stroke-width:" <<
MAX( 0.001, d->dc[d->level].style.stroke_width.value ) << "px;";
tmp_style << "stroke-linecap:" <<
(d->dc[d->level].style.stroke_linecap.computed == 0 ? "butt" :
d->dc[d->level].style.stroke_linecap.computed == 1 ? "round" :
d->dc[d->level].style.stroke_linecap.computed == 2 ? "square" :
"unknown") << ";";
tmp_style << "stroke-linejoin:" <<
(d->dc[d->level].style.stroke_linejoin.computed == 0 ? "miter" :
d->dc[d->level].style.stroke_linejoin.computed == 1 ? "round" :
d->dc[d->level].style.stroke_linejoin.computed == 2 ? "bevel" :
"unknown") << ";";
if (d->dc[d->level].style.stroke_linejoin.computed == 0) {
tmp_style << "stroke-miterlimit:" <<
MAX( 0.01, d->dc[d->level].style.stroke_miterlimit.value ) << ";";
}
if (d->dc[d->level].style.stroke_dasharray_set &&
d->dc[d->level].style.stroke_dash.n_dash && d->dc[d->level].style.stroke_dash.dash)
{
tmp_style << "stroke-dasharray:";
for (int i=0; i<d->dc[d->level].style.stroke_dash.n_dash; i++) {
if (i)
tmp_style << ",";
tmp_style << d->dc[d->level].style.stroke_dash.dash[i];
}
tmp_style << ";";
tmp_style << "stroke-dashoffset:0;";
} else {
tmp_style << "stroke-dasharray:none;";
}
tmp_style << "stroke-opacity:1;";
}
tmp_style << "\" ";
if (clipset)
tmp_style << "\n\tclip-path=\"url(#clipEmfPath" << d->id << ")\" ";
clipset = false;
*(d->outsvg) += tmp_style.str().c_str();
}
static double
_pix_x_to_point(PEMF_CALLBACK_DATA d, double px)
{
double tmp = px - d->dc[d->level].winorg.x;
tmp *= d->dc[d->level].ScaleInX ? d->dc[d->level].ScaleInX : 1.0;
tmp += d->dc[d->level].vieworg.x;
return tmp;
}
static double
_pix_y_to_point(PEMF_CALLBACK_DATA d, double px)
{
double tmp = px - d->dc[d->level].winorg.y;
tmp *= d->dc[d->level].ScaleInY ? d->dc[d->level].ScaleInY : 1.0;
tmp += d->dc[d->level].vieworg.y;
return tmp;
}
static double
pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
{
double ppx = _pix_x_to_point(d, px);
double ppy = _pix_y_to_point(d, py);
double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
x *= device_scale;
return x;
}
static double
pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py)
{
double ppx = _pix_x_to_point(d, px);
double ppy = _pix_y_to_point(d, py);
double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
y *= device_scale;
return y;
}
static double
pix_to_size_point(PEMF_CALLBACK_DATA d, double px)
{
double ppx = px * (d->dc[d->level].ScaleInX ? d->dc[d->level].ScaleInX : 1.0);
double ppy = 0;
double dx = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21;
dx *= device_scale;
double dy = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22;
dy *= device_scale;
double tmp = sqrt(dx * dx + dy * dy);
return tmp;
}
static void
select_pen(PEMF_CALLBACK_DATA d, int index)
{
PEMRCREATEPEN pEmr = NULL;
if (index >= 0 && index < d->n_obj)
pEmr = (PEMRCREATEPEN) d->emf_obj[index].lpEMFR;
if (!pEmr)
return;
switch (pEmr->lopn.lopnStyle & PS_STYLE_MASK) {
case PS_DASH:
case PS_DOT:
case PS_DASHDOT:
case PS_DASHDOTDOT:
{
int i = 0;
int penstyle = (pEmr->lopn.lopnStyle & PS_STYLE_MASK);
d->dc[d->level].style.stroke_dash.n_dash =
penstyle == PS_DASHDOTDOT ? 6 : penstyle == PS_DASHDOT ? 4 : 2;
if (d->dc[d->level].style.stroke_dash.dash && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dash.dash!=d->dc[d->level-1].style.stroke_dash.dash)))
delete[] d->dc[d->level].style.stroke_dash.dash;
d->dc[d->level].style.stroke_dash.dash = new double[d->dc[d->level].style.stroke_dash.n_dash];
if (penstyle==PS_DASH || penstyle==PS_DASHDOT || penstyle==PS_DASHDOTDOT) {
d->dc[d->level].style.stroke_dash.dash[i++] = 3;
d->dc[d->level].style.stroke_dash.dash[i++] = 1;
}
if (penstyle==PS_DOT || penstyle==PS_DASHDOT || penstyle==PS_DASHDOTDOT) {
d->dc[d->level].style.stroke_dash.dash[i++] = 1;
d->dc[d->level].style.stroke_dash.dash[i++] = 1;
}
if (penstyle==PS_DASHDOTDOT) {
d->dc[d->level].style.stroke_dash.dash[i++] = 1;
d->dc[d->level].style.stroke_dash.dash[i++] = 1;
}
d->dc[d->level].style.stroke_dasharray_set = 1;
break;
}
case PS_SOLID:
default:
{
d->dc[d->level].style.stroke_dasharray_set = 0;
break;
}
}
switch (pEmr->lopn.lopnStyle & PS_ENDCAP_MASK) {
case PS_ENDCAP_ROUND:
{
d->dc[d->level].style.stroke_linecap.computed = 1;
break;
}
case PS_ENDCAP_SQUARE:
{
d->dc[d->level].style.stroke_linecap.computed = 2;
break;
}
case PS_ENDCAP_FLAT:
default:
{
d->dc[d->level].style.stroke_linecap.computed = 0;
break;
}
}
switch (pEmr->lopn.lopnStyle & PS_JOIN_MASK) {
case PS_JOIN_BEVEL:
{
d->dc[d->level].style.stroke_linejoin.computed = 2;
break;
}
case PS_JOIN_MITER:
{
d->dc[d->level].style.stroke_linejoin.computed = 0;
break;
}
case PS_JOIN_ROUND:
default:
{
d->dc[d->level].style.stroke_linejoin.computed = 1;
break;
}
}
d->dc[d->level].stroke_set = true;
if (pEmr->lopn.lopnStyle == PS_NULL) {
d->dc[d->level].style.stroke_width.value = 0;
d->dc[d->level].stroke_set = false;
} else if (pEmr->lopn.lopnWidth.x) {
int cur_level = d->level;
d->level = d->emf_obj[index].level;
double pen_width = pix_to_size_point( d, pEmr->lopn.lopnWidth.x );
d->level = cur_level;
d->dc[d->level].style.stroke_width.value = pen_width;
} else { // this stroke should always be rendered as 1 pixel wide, independent of zoom level (can that be done in SVG?)
//d->dc[d->level].style.stroke_width.value = 1.0;
int cur_level = d->level;
d->level = d->emf_obj[index].level;
double pen_width = pix_to_size_point( d, 1 );
d->level = cur_level;
d->dc[d->level].style.stroke_width.value = pen_width;
}
double r, g, b;
r = SP_COLOR_U_TO_F( GetRValue(pEmr->lopn.lopnColor) );
g = SP_COLOR_U_TO_F( GetGValue(pEmr->lopn.lopnColor) );
b = SP_COLOR_U_TO_F( GetBValue(pEmr->lopn.lopnColor) );
d->dc[d->level].style.stroke.value.color.set( r, g, b );
}
static void
select_extpen(PEMF_CALLBACK_DATA d, int index)
{
PEMREXTCREATEPEN pEmr = NULL;
if (index >= 0 && index < d->n_obj)
pEmr = (PEMREXTCREATEPEN) d->emf_obj[index].lpEMFR;
if (!pEmr)
return;
switch (pEmr->elp.elpPenStyle & PS_STYLE_MASK) {
case PS_USERSTYLE:
{
if (pEmr->elp.elpNumEntries) {
d->dc[d->level].style.stroke_dash.n_dash = pEmr->elp.elpNumEntries;
if (d->dc[d->level].style.stroke_dash.dash && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dash.dash!=d->dc[d->level-1].style.stroke_dash.dash)))
delete[] d->dc[d->level].style.stroke_dash.dash;
d->dc[d->level].style.stroke_dash.dash = new double[pEmr->elp.elpNumEntries];
for (unsigned int i=0; i<pEmr->elp.elpNumEntries; i++) {
int cur_level = d->level;
d->level = d->emf_obj[index].level;
double dash_length = pix_to_size_point( d, pEmr->elp.elpStyleEntry[i] );
d->level = cur_level;
d->dc[d->level].style.stroke_dash.dash[i] = dash_length;
}
d->dc[d->level].style.stroke_dasharray_set = 1;
} else {
d->dc[d->level].style.stroke_dasharray_set = 0;
}
break;
}
case PS_DASH:
case PS_DOT:
case PS_DASHDOT:
case PS_DASHDOTDOT:
{
int i = 0;
int penstyle = (pEmr->elp.elpPenStyle & PS_STYLE_MASK);
d->dc[d->level].style.stroke_dash.n_dash =
penstyle == PS_DASHDOTDOT ? 6 : penstyle == PS_DASHDOT ? 4 : 2;
if (d->dc[d->level].style.stroke_dash.dash && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dash.dash!=d->dc[d->level-1].style.stroke_dash.dash)))
delete[] d->dc[d->level].style.stroke_dash.dash;
d->dc[d->level].style.stroke_dash.dash = new double[d->dc[d->level].style.stroke_dash.n_dash];
if (penstyle==PS_DASH || penstyle==PS_DASHDOT || penstyle==PS_DASHDOTDOT) {
d->dc[d->level].style.stroke_dash.dash[i++] = 3;
d->dc[d->level].style.stroke_dash.dash[i++] = 2;
}
if (penstyle==PS_DOT || penstyle==PS_DASHDOT || penstyle==PS_DASHDOTDOT) {
d->dc[d->level].style.stroke_dash.dash[i++] = 1;
d->dc[d->level].style.stroke_dash.dash[i++] = 2;
}
if (penstyle==PS_DASHDOTDOT) {
d->dc[d->level].style.stroke_dash.dash[i++] = 1;
d->dc[d->level].style.stroke_dash.dash[i++] = 2;
}
d->dc[d->level].style.stroke_dasharray_set = 1;
break;
}
case PS_SOLID:
default:
{
d->dc[d->level].style.stroke_dasharray_set = 0;
break;
}
}
switch (pEmr->elp.elpPenStyle & PS_ENDCAP_MASK) {
case PS_ENDCAP_ROUND:
{
d->dc[d->level].style.stroke_linecap.computed = 1;
break;
}
case PS_ENDCAP_SQUARE:
{
d->dc[d->level].style.stroke_linecap.computed = 2;
break;
}
case PS_ENDCAP_FLAT:
default:
{
d->dc[d->level].style.stroke_linecap.computed = 0;
break;
}
}
switch (pEmr->elp.elpPenStyle & PS_JOIN_MASK) {
case PS_JOIN_BEVEL:
{
d->dc[d->level].style.stroke_linejoin.computed = 2;
break;
}
case PS_JOIN_MITER:
{
d->dc[d->level].style.stroke_linejoin.computed = 0;
break;
}
case PS_JOIN_ROUND:
default:
{
d->dc[d->level].style.stroke_linejoin.computed = 1;
break;
}
}
d->dc[d->level].stroke_set = true;
if (pEmr->elp.elpPenStyle == PS_NULL) {
d->dc[d->level].style.stroke_width.value = 0;
d->dc[d->level].stroke_set = false;
} else if (pEmr->elp.elpWidth) {
int cur_level = d->level;
d->level = d->emf_obj[index].level;
double pen_width = pix_to_size_point( d, pEmr->elp.elpWidth );
d->level = cur_level;
d->dc[d->level].style.stroke_width.value = pen_width;
} else { // this stroke should always be rendered as 1 pixel wide, independent of zoom level (can that be done in SVG?)
//d->dc[d->level].style.stroke_width.value = 1.0;
int cur_level = d->level;
d->level = d->emf_obj[index].level;
double pen_width = pix_to_size_point( d, 1 );
d->level = cur_level;
d->dc[d->level].style.stroke_width.value = pen_width;
}
double r, g, b;
r = SP_COLOR_U_TO_F( GetRValue(pEmr->elp.elpColor) );
g = SP_COLOR_U_TO_F( GetGValue(pEmr->elp.elpColor) );
b = SP_COLOR_U_TO_F( GetBValue(pEmr->elp.elpColor) );
d->dc[d->level].style.stroke.value.color.set( r, g, b );
}
static void
select_brush(PEMF_CALLBACK_DATA d, int index)
{
PEMRCREATEBRUSHINDIRECT pEmr = NULL;
if (index >= 0 && index < d->n_obj)
pEmr = (PEMRCREATEBRUSHINDIRECT) d->emf_obj[index].lpEMFR;
if (!pEmr)
return;
if (pEmr->lb.lbStyle == BS_SOLID) {
double r, g, b;
r = SP_COLOR_U_TO_F( GetRValue(pEmr->lb.lbColor) );
g = SP_COLOR_U_TO_F( GetGValue(pEmr->lb.lbColor) );
b = SP_COLOR_U_TO_F( GetBValue(pEmr->lb.lbColor) );
d->dc[d->level].style.fill.value.color.set( r, g, b );
}
d->dc[d->level].fill_set = true;
}
static void
select_font(PEMF_CALLBACK_DATA d, int index)
{
PEMREXTCREATEFONTINDIRECTW pEmr = NULL;
if (index >= 0 && index < d->n_obj)
pEmr = (PEMREXTCREATEFONTINDIRECTW) d->emf_obj[index].lpEMFR;
if (!pEmr)
return;
int cur_level = d->level;
d->level = d->emf_obj[index].level;
double font_size = pix_to_size_point( d, pEmr->elfw.elfLogFont.lfHeight );
d->level = cur_level;
d->dc[d->level].style.font_size.computed = font_size;
d->dc[d->level].style.font_weight.value =
pEmr->elfw.elfLogFont.lfWeight == FW_THIN ? SP_CSS_FONT_WEIGHT_100 :
pEmr->elfw.elfLogFont.lfWeight == FW_EXTRALIGHT ? SP_CSS_FONT_WEIGHT_200 :
pEmr->elfw.elfLogFont.lfWeight == FW_LIGHT ? SP_CSS_FONT_WEIGHT_300 :
pEmr->elfw.elfLogFont.lfWeight == FW_NORMAL ? SP_CSS_FONT_WEIGHT_400 :
pEmr->elfw.elfLogFont.lfWeight == FW_MEDIUM ? SP_CSS_FONT_WEIGHT_500 :
pEmr->elfw.elfLogFont.lfWeight == FW_SEMIBOLD ? SP_CSS_FONT_WEIGHT_600 :
pEmr->elfw.elfLogFont.lfWeight == FW_BOLD ? SP_CSS_FONT_WEIGHT_700 :
pEmr->elfw.elfLogFont.lfWeight == FW_EXTRABOLD ? SP_CSS_FONT_WEIGHT_800 :
pEmr->elfw.elfLogFont.lfWeight == FW_HEAVY ? SP_CSS_FONT_WEIGHT_900 :
pEmr->elfw.elfLogFont.lfWeight == FW_NORMAL ? SP_CSS_FONT_WEIGHT_NORMAL :
pEmr->elfw.elfLogFont.lfWeight == FW_BOLD ? SP_CSS_FONT_WEIGHT_BOLD :
pEmr->elfw.elfLogFont.lfWeight == FW_EXTRALIGHT ? SP_CSS_FONT_WEIGHT_LIGHTER :
pEmr->elfw.elfLogFont.lfWeight == FW_EXTRABOLD ? SP_CSS_FONT_WEIGHT_BOLDER :
FW_NORMAL;
d->dc[d->level].style.font_style.value = (pEmr->elfw.elfLogFont.lfItalic ? SP_CSS_FONT_STYLE_ITALIC : SP_CSS_FONT_STYLE_NORMAL);
d->dc[d->level].style.text_decoration.underline = pEmr->elfw.elfLogFont.lfUnderline;
d->dc[d->level].style.text_decoration.line_through = pEmr->elfw.elfLogFont.lfStrikeOut;
if (d->dc[d->level].tstyle.font_family.value)
g_free(d->dc[d->level].tstyle.font_family.value);
d->dc[d->level].tstyle.font_family.value =
(gchar *) g_utf16_to_utf8( (gunichar2*) pEmr->elfw.elfLogFont.lfFaceName, -1, NULL, NULL, NULL );
d->dc[d->level].style.baseline_shift.value = ((pEmr->elfw.elfLogFont.lfEscapement + 3600) % 3600) / 10; // use baseline_shift instead of text_transform to avoid overflow
}
static void
delete_object(PEMF_CALLBACK_DATA d, int index)
{
if (index >= 0 && index < d->n_obj) {
d->emf_obj[index].type = 0;
if (d->emf_obj[index].lpEMFR)
free(d->emf_obj[index].lpEMFR);
d->emf_obj[index].lpEMFR = NULL;
}
}
static void
insert_object(PEMF_CALLBACK_DATA d, int index, int type, ENHMETARECORD *pObj)
{
if (index >= 0 && index < d->n_obj) {
delete_object(d, index);
d->emf_obj[index].type = type;
d->emf_obj[index].level = d->level;
d->emf_obj[index].lpEMFR = pObj;
}
}
static void
assert_empty_path(PEMF_CALLBACK_DATA d, const char * /*fun*/)
{
if (!d->path->empty()) {
// g_debug("emf-win32-inout: assert_empty_path failed for %s\n", fun);
*(d->outsvg) += "<!--\n";
*(d->outsvg) += " <path \t";
output_style(d, EMR_STROKEPATH);
if (strstr(d->path->c_str(), "d=\"") == NULL) {
*(d->outsvg) += "d=\"";
*(d->outsvg) += "\n\t";
}
*(d->outsvg) += *(d->path);
*(d->outsvg) += " \" /> \n";
*(d->outsvg) += "-->\n";
*(d->path) = "";
}
}
static int CALLBACK
myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *lpEMFR, int /*nObj*/, LPARAM lpData)
{
PEMF_CALLBACK_DATA d;
SVGOStringStream tmp_outsvg;
SVGOStringStream tmp_path;
SVGOStringStream tmp_str;
SVGOStringStream dbg_str;
d = (PEMF_CALLBACK_DATA) lpData;
if (d->pathless_stroke) {
if (lpEMFR->iType!=EMR_POLYBEZIERTO && lpEMFR->iType!=EMR_POLYBEZIERTO16 &&
lpEMFR->iType!=EMR_POLYLINETO && lpEMFR->iType!=EMR_POLYLINETO16 &&
lpEMFR->iType!=EMR_LINETO && lpEMFR->iType!=EMR_ARCTO &&
lpEMFR->iType!=EMR_SETBKCOLOR && lpEMFR->iType!=EMR_SETROP2 &&
lpEMFR->iType!=EMR_SETBKMODE && lpEMFR->iType!=EMR_SELECTOBJECT &&
lpEMFR->iType!=EMR_BEGINPATH)
{
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEPATH);
*(d->outsvg) += "\n\t";
*(d->outsvg) += *(d->path);
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
d->pathless_stroke = false;
}
}
switch (lpEMFR->iType)
{
case EMR_HEADER:
{
dbg_str << "<!-- EMR_HEADER -->\n";
*(d->outdef) += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
if (d->pDesc) {
*(d->outdef) += "<!-- ";
*(d->outdef) += d->pDesc;
*(d->outdef) += " -->\n";
}
ENHMETAHEADER *pEmr = (ENHMETAHEADER *) lpEMFR;
SVGOStringStream tmp_outdef;
tmp_outdef << "<svg\n";
tmp_outdef << " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
tmp_outdef << " xmlns=\"http://www.w3.org/2000/svg\"\n";
tmp_outdef << " version=\"1.0\"\n";
d->xDPI = 2540;
d->yDPI = 2540;
d->dc[d->level].PixelsInX = pEmr->rclFrame.right; // - pEmr->rclFrame.left;
d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom; // - pEmr->rclFrame.top;
d->MMX = d->dc[d->level].PixelsInX / 100.0;
d->MMY = d->dc[d->level].PixelsInY / 100.0;
d->dc[d->level].PixelsOutX = d->MMX * PX_PER_MM;
d->dc[d->level].PixelsOutY = d->MMY * PX_PER_MM;
// calculate ratio of Inkscape dpi/device dpi
if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx)
device_scale = PX_PER_MM*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx;
tmp_outdef <<
" width=\"" << d->MMX << "mm\"\n" <<
" height=\"" << d->MMY << "mm\">\n";
*(d->outdef) += tmp_outdef.str().c_str();
*(d->outdef) += "<defs>"; // temporary end of header
tmp_outsvg << "\n</defs>\n<g>\n"; // start of main body
if (pEmr->nHandles) {
d->n_obj = pEmr->nHandles;
d->emf_obj = new EMF_OBJECT[d->n_obj];
// Init the new emf_obj list elements to null, provided the
// dynamic allocation succeeded.
if ( d->emf_obj != NULL )
{
for( int i=0; i < d->n_obj; ++i )
d->emf_obj[i].lpEMFR = NULL;
} //if
} else {
d->emf_obj = NULL;
}
break;
}
case EMR_POLYBEZIER:
{
dbg_str << "<!-- EMR_POLYBEZIER -->\n";
PEMRPOLYBEZIER pEmr = (PEMRPOLYBEZIER) lpEMFR;
DWORD i,j;
if (pEmr->cptl<4)
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYBEZIER");
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEPATH);
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
pix_to_x_point( d, pEmr->aptl[0].x, pEmr->aptl[0].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[0].x, pEmr->aptl[0].y) << " ";
for (i=1; i<pEmr->cptl; ) {
tmp_str << "\n\tC ";
for (j=0; j<3 && i<pEmr->cptl; j++,i++) {
tmp_str <<
pix_to_x_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " ";
}
}
if (d->inpath) {
tmp_path << tmp_str.str().c_str();
}
else {
*(d->outsvg) += tmp_str.str().c_str();
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYGON:
{
dbg_str << "<!-- EMR_POLYGON -->\n";
EMRPOLYGON *pEmr = (EMRPOLYGON *) lpEMFR;
DWORD i;
if (pEmr->cptl < 2)
break;
assert_empty_path(d, "EMR_POLYGON");
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEANDFILLPATH);
*(d->outsvg) += "\n\td=\"";
tmp_str <<
"\n\tM " <<
pix_to_x_point( d, pEmr->aptl[0].x, pEmr->aptl[0].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[0].x, pEmr->aptl[0].y ) << " ";
for (i=1; i<pEmr->cptl; i++) {
tmp_str <<
"\n\tL " <<
pix_to_x_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " ";
}
*(d->outsvg) += tmp_str.str().c_str();
*(d->outsvg) += " z \" /> \n";
break;
}
case EMR_POLYLINE:
{
dbg_str << "<!-- EMR_POLYLINE -->\n";
EMRPOLYLINE *pEmr = (EMRPOLYLINE *) lpEMFR;
DWORD i;
if (pEmr->cptl<2)
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYLINE");
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEPATH);
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
pix_to_x_point( d, pEmr->aptl[0].x, pEmr->aptl[0].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[0].x, pEmr->aptl[0].y ) << " ";
for (i=1; i<pEmr->cptl; i++) {
tmp_str <<
"\n\tL " <<
pix_to_x_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " ";
}
if (d->inpath) {
tmp_path << tmp_str.str().c_str();
}
else {
*(d->outsvg) += tmp_str.str().c_str();
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYBEZIERTO:
{
dbg_str << "<!-- EMR_POLYBEZIERTO -->\n";
PEMRPOLYBEZIERTO pEmr = (PEMRPOLYBEZIERTO) lpEMFR;
DWORD i,j;
if (d->path->empty()) {
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
for (i=0; i<pEmr->cptl;) {
tmp_path << "\n\tC ";
for (j=0; j<3 && i<pEmr->cptl; j++,i++) {
tmp_path <<
pix_to_x_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " ";
}
}
break;
}
case EMR_POLYLINETO:
{
dbg_str << "<!-- EMR_POLYLINETO -->\n";
PEMRPOLYLINETO pEmr = (PEMRPOLYLINETO) lpEMFR;
DWORD i;
if (d->path->empty()) {
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
for (i=0; i<pEmr->cptl;i++) {
tmp_path <<
"\n\tL " <<
pix_to_x_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " " <<
pix_to_y_point( d, pEmr->aptl[i].x, pEmr->aptl[i].y ) << " ";
}
break;
}
case EMR_POLYPOLYLINE:
case EMR_POLYPOLYGON:
{
if (lpEMFR->iType == EMR_POLYPOLYLINE)
dbg_str << "<!-- EMR_POLYPOLYLINE -->\n";
if (lpEMFR->iType == EMR_POLYPOLYGON)
dbg_str << "<!-- EMR_POLYPOLYGON -->\n";
PEMRPOLYPOLYGON pEmr = (PEMRPOLYPOLYGON) lpEMFR;
unsigned int n, i, j;
if (!d->inpath) {
assert_empty_path(d, lpEMFR->iType == EMR_POLYPOLYGON ? "EMR_POLYPOLYGON" : "EMR_POLYPOLYLINE");
*(d->outsvg) += " <path ";
output_style(d, lpEMFR->iType==EMR_POLYPOLYGON ? EMR_STROKEANDFILLPATH : EMR_STROKEPATH);
*(d->outsvg) += "\n\td=\"";
}
POINTL *aptl = (POINTL *) &pEmr->aPolyCounts[pEmr->nPolys];
i = 0;
for (n=0; n<pEmr->nPolys && i<pEmr->cptl; n++) {
SVGOStringStream poly_path;
poly_path << "\n\tM " <<
pix_to_x_point( d, aptl[i].x, aptl[i].y ) << " " <<
pix_to_y_point( d, aptl[i].x, aptl[i].y ) << " ";
i++;
for (j=1; j<pEmr->aPolyCounts[n] && i<pEmr->cptl; j++) {
poly_path << "\n\tL " <<
pix_to_x_point( d, aptl[i].x, aptl[i].y ) << " " <<
pix_to_y_point( d, aptl[i].x, aptl[i].y ) << " ";
i++;
}
tmp_str << poly_path.str().c_str();
if (lpEMFR->iType == EMR_POLYPOLYGON)
tmp_str << " z";
tmp_str << " \n";
}
if (d->inpath) {
tmp_path << tmp_str.str().c_str();
}
else {
*(d->outsvg) += tmp_str.str().c_str();
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_SETWINDOWEXTEX:
{
dbg_str << "<!-- EMR_SETWINDOWEXTEX -->\n";
PEMRSETWINDOWEXTEX pEmr = (PEMRSETWINDOWEXTEX) lpEMFR;
d->dc[d->level].sizeWnd = pEmr->szlExtent;
if (!d->dc[d->level].sizeWnd.cx || !d->dc[d->level].sizeWnd.cy) {
d->dc[d->level].sizeWnd = d->dc[d->level].sizeView;
if (!d->dc[d->level].sizeWnd.cx || !d->dc[d->level].sizeWnd.cy) {
d->dc[d->level].sizeWnd.cx = d->dc[d->level].PixelsOutX;
d->dc[d->level].sizeWnd.cy = d->dc[d->level].PixelsOutY;
}
}
if (!d->dc[d->level].sizeView.cx || !d->dc[d->level].sizeView.cy) {
d->dc[d->level].sizeView = d->dc[d->level].sizeWnd;
}
d->dc[d->level].PixelsInX = d->dc[d->level].sizeWnd.cx;
d->dc[d->level].PixelsInY = d->dc[d->level].sizeWnd.cy;
if (d->dc[d->level].PixelsInX && d->dc[d->level].PixelsInY) {
d->dc[d->level].ScaleInX = (double) d->dc[d->level].sizeView.cx / (double) d->dc[d->level].PixelsInX;
d->dc[d->level].ScaleInY = (double) d->dc[d->level].sizeView.cy / (double) d->dc[d->level].PixelsInY;
}
else {
d->dc[d->level].ScaleInX = 1;
d->dc[d->level].ScaleInY = 1;
}
break;
}
case EMR_SETWINDOWORGEX:
{
dbg_str << "<!-- EMR_SETWINDOWORGEX -->\n";
PEMRSETWINDOWORGEX pEmr = (PEMRSETWINDOWORGEX) lpEMFR;
d->dc[d->level].winorg = pEmr->ptlOrigin;
break;
}
case EMR_SETVIEWPORTEXTEX:
{
dbg_str << "<!-- EMR_SETVIEWPORTEXTEX -->\n";
PEMRSETVIEWPORTEXTEX pEmr = (PEMRSETVIEWPORTEXTEX) lpEMFR;
d->dc[d->level].sizeView = pEmr->szlExtent;
if (!d->dc[d->level].sizeView.cx || !d->dc[d->level].sizeView.cy) {
d->dc[d->level].sizeView = d->dc[d->level].sizeWnd;
if (!d->dc[d->level].sizeView.cx || !d->dc[d->level].sizeView.cy) {
d->dc[d->level].sizeView.cx = d->dc[d->level].PixelsOutX;
d->dc[d->level].sizeView.cy = d->dc[d->level].PixelsOutY;
}
}
if (!d->dc[d->level].sizeWnd.cx || !d->dc[d->level].sizeWnd.cy) {
d->dc[d->level].sizeWnd = d->dc[d->level].sizeView;
}
d->dc[d->level].PixelsInX = d->dc[d->level].sizeWnd.cx;
d->dc[d->level].PixelsInY = d->dc[d->level].sizeWnd.cy;
if (d->dc[d->level].PixelsInX && d->dc[d->level].PixelsInY) {
d->dc[d->level].ScaleInX = (double) d->dc[d->level].sizeView.cx / (double) d->dc[d->level].PixelsInX;
d->dc[d->level].ScaleInY = (double) d->dc[d->level].sizeView.cy / (double) d->dc[d->level].PixelsInY;
}
else {
d->dc[d->level].ScaleInX = 1;
d->dc[d->level].ScaleInY = 1;
}
break;
}
case EMR_SETVIEWPORTORGEX:
{
dbg_str << "<!-- EMR_SETVIEWPORTORGEX -->\n";
PEMRSETVIEWPORTORGEX pEmr = (PEMRSETVIEWPORTORGEX) lpEMFR;
d->dc[d->level].vieworg = pEmr->ptlOrigin;
break;
}
case EMR_SETBRUSHORGEX:
dbg_str << "<!-- EMR_SETBRUSHORGEX -->\n";
break;
case EMR_EOF:
{
dbg_str << "<!-- EMR_EOF -->\n";
assert_empty_path(d, "EMR_EOF");
tmp_outsvg << "</g>\n";
tmp_outsvg << "</svg>\n";
*(d->outsvg) = *(d->outdef) + *(d->outsvg);
break;
}
case EMR_SETPIXELV:
dbg_str << "<!-- EMR_SETPIXELV -->\n";
break;
case EMR_SETMAPPERFLAGS:
dbg_str << "<!-- EMR_SETMAPPERFLAGS -->\n";
break;
case EMR_SETMAPMODE:
dbg_str << "<!-- EMR_SETMAPMODE -->\n";
break;
case EMR_SETBKMODE:
dbg_str << "<!-- EMR_SETBKMODE -->\n";
break;
case EMR_SETPOLYFILLMODE:
{
dbg_str << "<!-- EMR_SETPOLYFILLMODE -->\n";
PEMRSETPOLYFILLMODE pEmr = (PEMRSETPOLYFILLMODE) lpEMFR;
d->dc[d->level].style.fill_rule.value =
(pEmr->iMode == ALTERNATE ? 0 :
pEmr->iMode == WINDING ? 1 : 0);
break;
}
case EMR_SETROP2:
dbg_str << "<!-- EMR_SETROP2 -->\n";
break;
case EMR_SETSTRETCHBLTMODE:
dbg_str << "<!-- EMR_SETSTRETCHBLTMODE -->\n";
break;
case EMR_SETTEXTALIGN:
{
dbg_str << "<!-- EMR_SETTEXTALIGN -->\n";
PEMRSETTEXTALIGN pEmr = (PEMRSETTEXTALIGN) lpEMFR;
d->dc[d->level].textAlign = pEmr->iMode;
break;
}
case EMR_SETCOLORADJUSTMENT:
dbg_str << "<!-- EMR_SETCOLORADJUSTMENT -->\n";
break;
case EMR_SETTEXTCOLOR:
{
dbg_str << "<!-- EMR_SETTEXTCOLOR -->\n";
PEMRSETTEXTCOLOR pEmr = (PEMRSETTEXTCOLOR) lpEMFR;
d->dc[d->level].textColor = pEmr->crColor;
d->dc[d->level].textColorSet = true;
break;
}
case EMR_SETBKCOLOR:
dbg_str << "<!-- EMR_SETBKCOLOR -->\n";
break;
case EMR_OFFSETCLIPRGN:
dbg_str << "<!-- EMR_OFFSETCLIPRGN -->\n";
break;
case EMR_MOVETOEX:
{
dbg_str << "<!-- EMR_MOVETOEX -->\n";
PEMRMOVETOEX pEmr = (PEMRMOVETOEX) lpEMFR;
if (d->path->empty()) {
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
d->dc[d->level].cur = pEmr->ptl;
tmp_path <<
"\n\tM " <<
pix_to_x_point( d, pEmr->ptl.x, pEmr->ptl.y ) << " " <<
pix_to_y_point( d, pEmr->ptl.x, pEmr->ptl.y ) << " ";
break;
}
case EMR_SETMETARGN:
dbg_str << "<!-- EMR_SETMETARGN -->\n";
break;
case EMR_EXCLUDECLIPRECT:
dbg_str << "<!-- EMR_EXCLUDECLIPRECT -->\n";
break;
case EMR_INTERSECTCLIPRECT:
{
dbg_str << "<!-- EMR_INTERSECTCLIPRECT -->\n";
PEMRINTERSECTCLIPRECT pEmr = (PEMRINTERSECTCLIPRECT) lpEMFR;
RECTL rc = pEmr->rclClip;
clipset = true;
if ((rc.left == rc_old.left) && (rc.top == rc_old.top) && (rc.right == rc_old.right) && (rc.bottom == rc_old.bottom))
break;
rc_old = rc;
double l = pix_to_x_point( d, rc.left, rc.top );
double t = pix_to_y_point( d, rc.left, rc.top );
double r = pix_to_x_point( d, rc.right, rc.bottom );
double b = pix_to_y_point( d, rc.right, rc.bottom );
SVGOStringStream tmp_rectangle;
tmp_rectangle << "\n<clipPath\n\tclipPathUnits=\"userSpaceOnUse\" ";
tmp_rectangle << "\n\tid=\"clipEmfPath" << ++(d->id) << "\" >";
tmp_rectangle << "\n<rect ";
tmp_rectangle << "\n\tx=\"" << l << "\" ";
tmp_rectangle << "\n\ty=\"" << t << "\" ";
tmp_rectangle << "\n\twidth=\"" << r-l << "\" ";
tmp_rectangle << "\n\theight=\"" << b-t << "\" />";
tmp_rectangle << "\n</clipPath>";
assert_empty_path(d, "EMR_RECTANGLE");
*(d->outdef) += tmp_rectangle.str().c_str();
*(d->path) = "";
break;
}
case EMR_SCALEVIEWPORTEXTEX:
dbg_str << "<!-- EMR_SCALEVIEWPORTEXTEX -->\n";
break;
case EMR_SCALEWINDOWEXTEX:
dbg_str << "<!-- EMR_SCALEWINDOWEXTEX -->\n";
break;
case EMR_SAVEDC:
dbg_str << "<!-- EMR_SAVEDC -->\n";
if (d->level < EMF_MAX_DC) {
d->dc[d->level + 1] = d->dc[d->level];
d->level = d->level + 1;
}
break;
case EMR_RESTOREDC:
{
dbg_str << "<!-- EMR_RESTOREDC -->\n";
PEMRRESTOREDC pEmr = (PEMRRESTOREDC) lpEMFR;
int old_level = d->level;
if (pEmr->iRelative >= 0) {
if (pEmr->iRelative < d->level)
d->level = pEmr->iRelative;
}
else {
if (d->level + pEmr->iRelative >= 0)
d->level = d->level + pEmr->iRelative;
}
while (old_level > d->level) {
if (d->dc[old_level].style.stroke_dash.dash && (old_level==0 || (old_level>0 && d->dc[old_level].style.stroke_dash.dash!=d->dc[old_level-1].style.stroke_dash.dash)))
delete[] d->dc[old_level].style.stroke_dash.dash;
old_level--;
}
break;
}
case EMR_SETWORLDTRANSFORM:
{
dbg_str << "<!-- EMR_SETWORLDTRANSFORM -->\n";
PEMRSETWORLDTRANSFORM pEmr = (PEMRSETWORLDTRANSFORM) lpEMFR;
d->dc[d->level].worldTransform = pEmr->xform;
break;
}
case EMR_MODIFYWORLDTRANSFORM:
{
dbg_str << "<!-- EMR_MODIFYWORLDTRANSFORM -->\n";
PEMRMODIFYWORLDTRANSFORM pEmr = (PEMRMODIFYWORLDTRANSFORM) lpEMFR;
switch (pEmr->iMode)
{
case MWT_IDENTITY:
d->dc[d->level].worldTransform.eM11 = 1.0;
d->dc[d->level].worldTransform.eM12 = 0.0;
d->dc[d->level].worldTransform.eM21 = 0.0;
d->dc[d->level].worldTransform.eM22 = 1.0;
d->dc[d->level].worldTransform.eDx = 0.0;
d->dc[d->level].worldTransform.eDy = 0.0;
break;
case MWT_LEFTMULTIPLY:
{
// d->dc[d->level].worldTransform = pEmr->xform * worldTransform;
float a11 = pEmr->xform.eM11;
float a12 = pEmr->xform.eM12;
float a13 = 0.0;
float a21 = pEmr->xform.eM21;
float a22 = pEmr->xform.eM22;
float a23 = 0.0;
float a31 = pEmr->xform.eDx;
float a32 = pEmr->xform.eDy;
float a33 = 1.0;
float b11 = d->dc[d->level].worldTransform.eM11;
float b12 = d->dc[d->level].worldTransform.eM12;
//float b13 = 0.0;
float b21 = d->dc[d->level].worldTransform.eM21;
float b22 = d->dc[d->level].worldTransform.eM22;
//float b23 = 0.0;
float b31 = d->dc[d->level].worldTransform.eDx;
float b32 = d->dc[d->level].worldTransform.eDy;
//float b33 = 1.0;
float c11 = a11*b11 + a12*b21 + a13*b31;;
float c12 = a11*b12 + a12*b22 + a13*b32;;
//float c13 = a11*b13 + a12*b23 + a13*b33;;
float c21 = a21*b11 + a22*b21 + a23*b31;;
float c22 = a21*b12 + a22*b22 + a23*b32;;
//float c23 = a21*b13 + a22*b23 + a23*b33;;
float c31 = a31*b11 + a32*b21 + a33*b31;;
float c32 = a31*b12 + a32*b22 + a33*b32;;
//float c33 = a31*b13 + a32*b23 + a33*b33;;
d->dc[d->level].worldTransform.eM11 = c11;;
d->dc[d->level].worldTransform.eM12 = c12;;
d->dc[d->level].worldTransform.eM21 = c21;;
d->dc[d->level].worldTransform.eM22 = c22;;
d->dc[d->level].worldTransform.eDx = c31;
d->dc[d->level].worldTransform.eDy = c32;
break;
}
case MWT_RIGHTMULTIPLY:
{
// d->dc[d->level].worldTransform = worldTransform * pEmr->xform;
float a11 = d->dc[d->level].worldTransform.eM11;
float a12 = d->dc[d->level].worldTransform.eM12;
float a13 = 0.0;
float a21 = d->dc[d->level].worldTransform.eM21;
float a22 = d->dc[d->level].worldTransform.eM22;
float a23 = 0.0;
float a31 = d->dc[d->level].worldTransform.eDx;
float a32 = d->dc[d->level].worldTransform.eDy;
float a33 = 1.0;
float b11 = pEmr->xform.eM11;
float b12 = pEmr->xform.eM12;
//float b13 = 0.0;
float b21 = pEmr->xform.eM21;
float b22 = pEmr->xform.eM22;
//float b23 = 0.0;
float b31 = pEmr->xform.eDx;
float b32 = pEmr->xform.eDy;
//float b33 = 1.0;
float c11 = a11*b11 + a12*b21 + a13*b31;;
float c12 = a11*b12 + a12*b22 + a13*b32;;
//float c13 = a11*b13 + a12*b23 + a13*b33;;
float c21 = a21*b11 + a22*b21 + a23*b31;;
float c22 = a21*b12 + a22*b22 + a23*b32;;
//float c23 = a21*b13 + a22*b23 + a23*b33;;
float c31 = a31*b11 + a32*b21 + a33*b31;;
float c32 = a31*b12 + a32*b22 + a33*b32;;
//float c33 = a31*b13 + a32*b23 + a33*b33;;
d->dc[d->level].worldTransform.eM11 = c11;;
d->dc[d->level].worldTransform.eM12 = c12;;
d->dc[d->level].worldTransform.eM21 = c21;;
d->dc[d->level].worldTransform.eM22 = c22;;
d->dc[d->level].worldTransform.eDx = c31;
d->dc[d->level].worldTransform.eDy = c32;
break;
}
// case MWT_SET:
default:
d->dc[d->level].worldTransform = pEmr->xform;
break;
}
break;
}
case EMR_SELECTOBJECT:
{
dbg_str << "<!-- EMR_SELECTOBJECT -->\n";
PEMRSELECTOBJECT pEmr = (PEMRSELECTOBJECT) lpEMFR;
unsigned int index = pEmr->ihObject;
if (index >= ENHMETA_STOCK_OBJECT) {
index -= ENHMETA_STOCK_OBJECT;
switch (index) {
case NULL_BRUSH:
d->dc[d->level].fill_set = false;
break;
case BLACK_BRUSH:
case DKGRAY_BRUSH:
case GRAY_BRUSH:
case LTGRAY_BRUSH:
case WHITE_BRUSH:
{
float val = 0;
switch (index) {
case BLACK_BRUSH:
val = 0.0 / 255.0;
break;
case DKGRAY_BRUSH:
val = 64.0 / 255.0;
break;
case GRAY_BRUSH:
val = 128.0 / 255.0;
break;
case LTGRAY_BRUSH:
val = 192.0 / 255.0;
break;
case WHITE_BRUSH:
val = 255.0 / 255.0;
break;
}
d->dc[d->level].style.fill.value.color.set( val, val, val );
d->dc[d->level].fill_set = true;
break;
}
case NULL_PEN:
d->dc[d->level].stroke_set = false;
break;
case BLACK_PEN:
case WHITE_PEN:
{
float val = index == BLACK_PEN ? 0 : 1;
d->dc[d->level].style.stroke_dasharray_set = 0;
d->dc[d->level].style.stroke_width.value = 1.0;
d->dc[d->level].style.stroke.value.color.set( val, val, val );
d->dc[d->level].stroke_set = true;
break;
}
}
} else {
if ( /*index >= 0 &&*/ index < (unsigned int) d->n_obj) {
switch (d->emf_obj[index].type)
{
case EMR_CREATEPEN:
select_pen(d, index);
break;
case EMR_CREATEBRUSHINDIRECT:
select_brush(d, index);
break;
case EMR_EXTCREATEPEN:
select_extpen(d, index);
break;
case EMR_EXTCREATEFONTINDIRECTW:
select_font(d, index);
break;
}
}
}
break;
}
case EMR_CREATEPEN:
{
dbg_str << "<!-- EMR_CREATEPEN -->\n";
PEMRCREATEPEN pEmr = (PEMRCREATEPEN) lpEMFR;
int index = pEmr->ihPen;
EMRCREATEPEN *pPen =
(EMRCREATEPEN *) malloc( sizeof(EMRCREATEPEN) );
pPen->lopn = pEmr->lopn;
insert_object(d, index, EMR_CREATEPEN, (ENHMETARECORD *) pPen);
break;
}
case EMR_CREATEBRUSHINDIRECT:
{
dbg_str << "<!-- EMR_CREATEBRUSHINDIRECT -->\n";
PEMRCREATEBRUSHINDIRECT pEmr = (PEMRCREATEBRUSHINDIRECT) lpEMFR;
int index = pEmr->ihBrush;
EMRCREATEBRUSHINDIRECT *pBrush =
(EMRCREATEBRUSHINDIRECT *) malloc( sizeof(EMRCREATEBRUSHINDIRECT) );
pBrush->lb = pEmr->lb;
insert_object(d, index, EMR_CREATEBRUSHINDIRECT, (ENHMETARECORD *) pBrush);
break;
}
case EMR_DELETEOBJECT:
dbg_str << "<!-- EMR_DELETEOBJECT -->\n";
break;
case EMR_ANGLEARC:
dbg_str << "<!-- EMR_ANGLEARC -->\n";
break;
case EMR_ELLIPSE:
{
dbg_str << "<!-- EMR_ELLIPSE -->\n";
PEMRELLIPSE pEmr = (PEMRELLIPSE) lpEMFR;
RECTL rclBox = pEmr->rclBox;
double l = pix_to_x_point( d, pEmr->rclBox.left, pEmr->rclBox.top );
double t = pix_to_y_point( d, pEmr->rclBox.left, pEmr->rclBox.top );
double r = pix_to_x_point( d, pEmr->rclBox.right, pEmr->rclBox.bottom );
double b = pix_to_y_point( d, pEmr->rclBox.right, pEmr->rclBox.bottom );
double cx = (l + r) / 2.0;
double cy = (t + b) / 2.0;
double rx = fabs(l - r) / 2.0;
double ry = fabs(t - b) / 2.0;
SVGOStringStream tmp_ellipse;
tmp_ellipse << "cx=\"" << cx << "\" ";
tmp_ellipse << "cy=\"" << cy << "\" ";
tmp_ellipse << "rx=\"" << rx << "\" ";
tmp_ellipse << "ry=\"" << ry << "\" ";
assert_empty_path(d, "EMR_ELLIPSE");
*(d->outsvg) += " <ellipse ";
output_style(d, lpEMFR->iType);
*(d->outsvg) += "\n\t";
*(d->outsvg) += tmp_ellipse.str().c_str();
*(d->outsvg) += "/> \n";
*(d->path) = "";
break;
}
case EMR_RECTANGLE:
{
dbg_str << "<!-- EMR_RECTANGLE -->\n";
PEMRRECTANGLE pEmr = (PEMRRECTANGLE) lpEMFR;
RECTL rc = pEmr->rclBox;
double l = pix_to_x_point( d, rc.left, rc.top );
double t = pix_to_y_point( d, rc.left, rc.top );
double r = pix_to_x_point( d, rc.right, rc.bottom );
double b = pix_to_y_point( d, rc.right, rc.bottom );
SVGOStringStream tmp_rectangle;
tmp_rectangle << "d=\"";
tmp_rectangle << "\n\tM " << l << " " << t << " ";
tmp_rectangle << "\n\tL " << r << " " << t << " ";
tmp_rectangle << "\n\tL " << r << " " << b << " ";
tmp_rectangle << "\n\tL " << l << " " << b << " ";
tmp_rectangle << "\n\tz";
assert_empty_path(d, "EMR_RECTANGLE");
*(d->outsvg) += " <path ";
output_style(d, lpEMFR->iType);
*(d->outsvg) += "\n\t";
*(d->outsvg) += tmp_rectangle.str().c_str();
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
break;
}
case EMR_ROUNDRECT:
{
dbg_str << "<!-- EMR_ROUNDRECT -->\n";
PEMRROUNDRECT pEmr = (PEMRROUNDRECT) lpEMFR;
RECTL rc = pEmr->rclBox;
SIZEL corner = pEmr->szlCorner;
double f = 4.*(sqrt(2) - 1)/3;
double l = pix_to_x_point(d, rc.left, rc.top);
double t = pix_to_y_point(d, rc.left, rc.top);
double r = pix_to_x_point(d, rc.right, rc.bottom);
double b = pix_to_y_point(d, rc.right, rc.bottom);
double cnx = pix_to_size_point(d, corner.cx/2);
double cny = pix_to_size_point(d, corner.cy/2);
SVGOStringStream tmp_rectangle;
tmp_rectangle << "d=\"";
tmp_rectangle << "\n\tM " << l << ", " << t + cny << " ";
tmp_rectangle << "\n\tC " << l << ", " << t + (1-f)*cny << " " << l + (1-f)*cnx << ", " << t << " " << l + cnx << ", " << t << " ";
tmp_rectangle << "\n\tL " << r - cnx << ", " << t << " ";
tmp_rectangle << "\n\tC " << r - (1-f)*cnx << ", " << t << " " << r << ", " << t + (1-f)*cny << " " << r << ", " << t + cny << " ";
tmp_rectangle << "\n\tL " << r << ", " << b - cny << " ";
tmp_rectangle << "\n\tC " << r << ", " << b - (1-f)*cny << " " << r - (1-f)*cnx << ", " << b << " " << r - cnx << ", " << b << " ";
tmp_rectangle << "\n\tL " << l + cnx << ", " << b << " ";
tmp_rectangle << "\n\tC " << l + (1-f)*cnx << ", " << b << " " << l << ", " << b - (1-f)*cny << " " << l << ", " << b - cny << " ";
tmp_rectangle << "\n\tz";
assert_empty_path(d, "EMR_ROUNDRECT");
*(d->outsvg) += " <path ";
output_style(d, lpEMFR->iType);
*(d->outsvg) += "\n\t";
*(d->outsvg) += tmp_rectangle.str().c_str();
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
break;
}
case EMR_ARC:
dbg_str << "<!-- EMR_ARC -->\n";
break;
case EMR_CHORD:
dbg_str << "<!-- EMR_CHORD -->\n";
break;
case EMR_PIE:
{
dbg_str << "<!-- EMR_PIE -->\n";
PEMRPIE pEmr = (PEMRPIE) lpEMFR;
RECTL rc = pEmr->rclBox;
double l = pix_to_x_point( d, rc.left, rc.top );
double t = pix_to_y_point( d, rc.left, rc.top );
double r = pix_to_x_point( d, rc.right, rc.bottom );
double b = pix_to_y_point( d, rc.right, rc.bottom );
double x1 = pix_to_x_point( d, pEmr->ptlStart.x, pEmr->ptlStart.y );
double y1 = pix_to_y_point( d, pEmr->ptlStart.x, pEmr->ptlStart.y );
double x2 = pix_to_x_point( d, pEmr->ptlEnd.x, pEmr->ptlEnd.y );
double y2 = pix_to_y_point( d, pEmr->ptlEnd.x, pEmr->ptlEnd.y );
SVGOStringStream tmp_pie;
tmp_pie << "d=\"" <<
"\n\tM " << x1 << " " << y1 << " ";
double angle1 = -atan2(y1 - (t + b) / 2.0, x1 - (l + r) / 2.0);
double angle2 = -atan2(y2 - (t + b) / 2.0, x2 - (l + r) / 2.0);
double angle = angle2 - angle1;
if (angle < 0) angle += 2*M_PI;
bool large_arc_flag = false;
if (angle > M_PI) large_arc_flag = true;
tmp_pie << "\n\tA " <<
fabs(l - r) / 2.0 << " " <<
fabs(t - b) / 2.0 << " " <<
"0 " << large_arc_flag << " 0 " <<
x2 << " " << y2 << " " <<
"\n\tL " << (l + r) / 2.0 << " " << (t + b) / 2.0 << " " <<
"\n\tz";
assert_empty_path(d, "EMR_PIE");
*(d->outsvg) += " <path ";
output_style(d, lpEMFR->iType);
*(d->outsvg) += "\n\t";
*(d->outsvg) += tmp_pie.str().c_str();
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
break;
}
case EMR_SELECTPALETTE:
dbg_str << "<!-- EMR_SELECTPALETTE -->\n";
break;
case EMR_CREATEPALETTE:
dbg_str << "<!-- EMR_CREATEPALETTE -->\n";
break;
case EMR_SETPALETTEENTRIES:
dbg_str << "<!-- EMR_SETPALETTEENTRIES -->\n";
break;
case EMR_RESIZEPALETTE:
dbg_str << "<!-- EMR_RESIZEPALETTE -->\n";
break;
case EMR_REALIZEPALETTE:
dbg_str << "<!-- EMR_REALIZEPALETTE -->\n";
break;
case EMR_EXTFLOODFILL:
dbg_str << "<!-- EMR_EXTFLOODFILL -->\n";
break;
case EMR_LINETO:
{
dbg_str << "<!-- EMR_LINETO -->\n";
PEMRLINETO pEmr = (PEMRLINETO) lpEMFR;
if (d->path->empty()) {
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
tmp_path <<
"\n\tL " <<
pix_to_x_point( d, pEmr->ptl.x, pEmr->ptl.y ) << " " <<
pix_to_y_point( d, pEmr->ptl.x, pEmr->ptl.y ) << " ";
break;
}
case EMR_ARCTO:
dbg_str << "<!-- EMR_ARCTO -->\n";
break;
case EMR_POLYDRAW:
dbg_str << "<!-- EMR_POLYDRAW -->\n";
break;
case EMR_SETARCDIRECTION:
dbg_str << "<!-- EMR_SETARCDIRECTION -->\n";
break;
case EMR_SETMITERLIMIT:
{
dbg_str << "<!-- EMR_SETMITERLIMIT -->\n";
PEMRSETMITERLIMIT pEmr = (PEMRSETMITERLIMIT) lpEMFR;
//BUG in SetMiterLimit() on mingw, possibly in underlying Windows(at least on XP?)
//The function takes a float but saves a 32 bit int in the EMR_SETMITERLIMIT record.
float miterlimit = *((int32_t *) &(pEmr->eMiterLimit));
d->dc[d->level].style.stroke_miterlimit.value = miterlimit; //ratio, not a pt size
if (d->dc[d->level].style.stroke_miterlimit.value < 1.0)
d->dc[d->level].style.stroke_miterlimit.value = 1.0;
break;
}
case EMR_BEGINPATH:
{
dbg_str << "<!-- EMR_BEGINPATH -->\n";
if (!d->pathless_stroke) {
tmp_path << "d=\"";
*(d->path) = "";
}
d->pathless_stroke = false;
d->inpath = true;
break;
}
case EMR_ENDPATH:
{
dbg_str << "<!-- EMR_ENDPATH -->\n";
tmp_path << "\"";
d->inpath = false;
break;
}
case EMR_CLOSEFIGURE:
{
dbg_str << "<!-- EMR_CLOSEFIGURE -->\n";
tmp_path << "\n\tz";
break;
}
case EMR_FILLPATH:
case EMR_STROKEANDFILLPATH:
case EMR_STROKEPATH:
{
if (lpEMFR->iType == EMR_FILLPATH)
dbg_str << "<!-- EMR_FILLPATH -->\n";
if (lpEMFR->iType == EMR_STROKEANDFILLPATH)
dbg_str << "<!-- EMR_STROKEANDFILLPATH -->\n";
if (lpEMFR->iType == EMR_STROKEPATH)
dbg_str << "<!-- EMR_STROKEPATH -->\n";
*(d->outsvg) += " <path ";
output_style(d, lpEMFR->iType);
*(d->outsvg) += "\n\t";
*(d->outsvg) += *(d->path);
*(d->outsvg) += " /> \n";
*(d->path) = "";
break;
}
case EMR_FLATTENPATH:
dbg_str << "<!-- EMR_FLATTENPATH -->\n";
break;
case EMR_WIDENPATH:
dbg_str << "<!-- EMR_WIDENPATH -->\n";
break;
case EMR_SELECTCLIPPATH:
dbg_str << "<!-- EMR_SELECTCLIPPATH -->\n";
break;
case EMR_ABORTPATH:
dbg_str << "<!-- EMR_ABORTPATH -->\n";
break;
case EMR_GDICOMMENT:
{
dbg_str << "<!-- EMR_GDICOMMENT -->\n";
PEMRGDICOMMENT pEmr = (PEMRGDICOMMENT) lpEMFR;
CHAR *szTxt = (CHAR *) pEmr->Data;
for (DWORD i = 0; i < pEmr->cbData; i++) {
if ( *szTxt) {
if ( *szTxt >= ' ' && *szTxt < 'z' && *szTxt != '<' && *szTxt != '>' ) {
tmp_str << *szTxt;
}
szTxt++;
}
}
if (0 && strlen(tmp_str.str().c_str())) {
tmp_outsvg << " <!-- \"";
tmp_outsvg << tmp_str.str().c_str();
tmp_outsvg << "\" -->\n";
}
break;
}
case EMR_FILLRGN:
dbg_str << "<!-- EMR_FILLRGN -->\n";
break;
case EMR_FRAMERGN:
dbg_str << "<!-- EMR_FRAMERGN -->\n";
break;
case EMR_INVERTRGN:
dbg_str << "<!-- EMR_INVERTRGN -->\n";
break;
case EMR_PAINTRGN:
dbg_str << "<!-- EMR_PAINTRGN -->\n";
break;
case EMR_EXTSELECTCLIPRGN:
{
dbg_str << "<!-- EMR_EXTSELECTCLIPRGN -->\n";
PEMREXTSELECTCLIPRGN pEmr = (PEMREXTSELECTCLIPRGN) lpEMFR;
if (pEmr->iMode == RGN_COPY)
clipset = false;
break;
}
case EMR_BITBLT:
{
dbg_str << "<!-- EMR_BITBLT -->\n";
PEMRBITBLT pEmr = (PEMRBITBLT) lpEMFR;
if ((pEmr->dwRop == PATCOPY) || (pEmr->dwRop == DPA)) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
double l = pix_to_x_point( d, pEmr->xDest, pEmr->yDest);
double t = pix_to_y_point( d, pEmr->xDest, pEmr->yDest);
double r = pix_to_x_point( d, pEmr->xDest + pEmr->cxDest, pEmr->yDest + pEmr->cyDest);
double b = pix_to_y_point( d, pEmr->xDest + pEmr->cxDest, pEmr->yDest + pEmr->cyDest);
SVGOStringStream tmp_rectangle;
tmp_rectangle << "d=\"";
tmp_rectangle << "\n\tM " << l << " " << t << " ";
tmp_rectangle << "\n\tL " << r << " " << t << " ";
tmp_rectangle << "\n\tL " << r << " " << b << " ";
tmp_rectangle << "\n\tL " << l << " " << b << " ";
tmp_rectangle << "\n\tz";
assert_empty_path(d, "EMR_BITBLT");
*(d->outsvg) += " <path ";
output_style(d, lpEMFR->iType);
*(d->outsvg) += "\n\t";
*(d->outsvg) += tmp_rectangle.str().c_str();
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
}
break;
}
case EMR_STRETCHBLT:
dbg_str << "<!-- EMR_STRETCHBLT -->\n";
break;
case EMR_MASKBLT:
dbg_str << "<!-- EMR_MASKBLT -->\n";
break;
case EMR_PLGBLT:
dbg_str << "<!-- EMR_PLGBLT -->\n";
break;
case EMR_SETDIBITSTODEVICE:
dbg_str << "<!-- EMR_SETDIBITSTODEVICE -->\n";
break;
case EMR_STRETCHDIBITS:
dbg_str << "<!-- EMR_STRETCHDIBITS -->\n";
break;
case EMR_EXTCREATEFONTINDIRECTW:
{
dbg_str << "<!-- EMR_EXTCREATEFONTINDIRECTW -->\n";
PEMREXTCREATEFONTINDIRECTW pEmr = (PEMREXTCREATEFONTINDIRECTW) lpEMFR;
int index = pEmr->ihFont;
EMREXTCREATEFONTINDIRECTW *pFont =
(EMREXTCREATEFONTINDIRECTW *) malloc( sizeof(EMREXTCREATEFONTINDIRECTW) );
pFont->elfw = pEmr->elfw;
insert_object(d, index, EMR_EXTCREATEFONTINDIRECTW, (ENHMETARECORD *) pFont);
break;
}
case EMR_EXTTEXTOUTA:
{
dbg_str << "<!-- EMR_EXTTEXTOUTA -->\n";
break;
}
case EMR_EXTTEXTOUTW:
{
dbg_str << "<!-- EMR_EXTTEXTOUTW -->\n";
PEMREXTTEXTOUTW pEmr = (PEMREXTTEXTOUTW) lpEMFR;
double x1 = pEmr->emrtext.ptlReference.x;
double y1 = pEmr->emrtext.ptlReference.y;
if (d->dc[d->level].textAlign & TA_UPDATECP) {
x1 = d->dc[d->level].cur.x;
y1 = d->dc[d->level].cur.y;
}
double x = pix_to_x_point(d, x1, y1);
double y = pix_to_y_point(d, x1, y1);
if (!(d->dc[d->level].textAlign & TA_BOTTOM))
if (d->dc[d->level].style.baseline_shift.value) {
x += std::sin(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
y += std::cos(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
}
else
y += fabs(d->dc[d->level].style.font_size.computed);
wchar_t *wide_text = (wchar_t *) ((char *) pEmr + pEmr->emrtext.offString);
gchar *ansi_text =
(gchar *) g_utf16_to_utf8( (gunichar2 *) wide_text, pEmr->emrtext.nChars, NULL, NULL, NULL );
if (ansi_text) {
if ((wide_text[0] < 32) && (strlen(ansi_text) == 1)) {
g_free(ansi_text); // filter out isolated control characters
ansi_text = g_strdup("");
}
// gchar *p = ansi_text;
// while (*p) {
// if (*p < 32 || *p >= 127) {
// g_free(ansi_text);
// ansi_text = g_strdup("");
// break;
// }
// p++;
// }
SVGOStringStream ts;
gchar *escaped_text = g_markup_escape_text(ansi_text, -1);
// float text_rgb[3];
// sp_color_get_rgb_floatv( &(d->dc[d->level].style.fill.value.color), text_rgb );
// if (!d->dc[d->level].textColorSet) {
// d->dc[d->level].textColor = RGB(SP_COLOR_F_TO_U(text_rgb[0]),
// SP_COLOR_F_TO_U(text_rgb[1]),
// SP_COLOR_F_TO_U(text_rgb[2]));
// }
char tmp[128];
snprintf(tmp, 127,
"fill:#%02x%02x%02x;",
GetRValue(d->dc[d->level].textColor),
GetGValue(d->dc[d->level].textColor),
GetBValue(d->dc[d->level].textColor));
bool i = (d->dc[d->level].style.font_style.value == SP_CSS_FONT_STYLE_ITALIC);
//bool o = (d->dc[d->level].style.font_style.value == SP_CSS_FONT_STYLE_OBLIQUE);
bool b = (d->dc[d->level].style.font_weight.value == SP_CSS_FONT_WEIGHT_BOLD) ||
(d->dc[d->level].style.font_weight.value >= SP_CSS_FONT_WEIGHT_500 && d->dc[d->level].style.font_weight.value <= SP_CSS_FONT_WEIGHT_900);
int lcr = ((d->dc[d->level].textAlign & TA_CENTER) == TA_CENTER) ? 2 : ((d->dc[d->level].textAlign & TA_RIGHT) == TA_RIGHT) ? 1 : 0;
assert_empty_path(d, "EMR_EXTTEXTOUTW");
ts << " <text\n";
// ts << " id=\"" << (d->id++) << "\"\n";
ts << " xml:space=\"preserve\"\n";
ts << " x=\"" << x << "\"\n";
ts << " y=\"" << y << "\"\n";
if (d->dc[d->level].style.baseline_shift.value) {
ts << " transform=\""
<< "rotate(-" << d->dc[d->level].style.baseline_shift.value
<< " " << x << " " << y << ")"
<< "\"\n";
}
ts << " style=\""
<< "font-size:" << fabs(d->dc[d->level].style.font_size.computed) << "px;"
<< tmp
<< "font-style:" << (i ? "italic" : "normal") << ";"
<< "font-weight:" << (b ? "bold" : "normal") << ";"
<< "text-align:" << (lcr==2 ? "center" : lcr==1 ? "end" : "start") << ";"
<< "text-anchor:" << (lcr==2 ? "middle" : lcr==1 ? "end" : "start") << ";"
<< "font-family:" << d->dc[d->level].tstyle.font_family.value << ";"
<< "\"\n";
ts << " >";
ts << escaped_text;
ts << "</text>\n";
*(d->outsvg) += ts.str().c_str();
g_free(escaped_text);
g_free(ansi_text);
}
break;
}
case EMR_POLYBEZIER16:
{
dbg_str << "<!-- EMR_POLYBEZIER16 -->\n";
PEMRPOLYBEZIER16 pEmr = (PEMRPOLYBEZIER16) lpEMFR;
POINTS *apts = (POINTS *) pEmr->apts; // Bug in MinGW wingdi.h ?
DWORD i,j;
if (pEmr->cpts<4)
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYBEZIER16");
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEPATH);
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
pix_to_x_point( d, apts[0].x, apts[0].y ) << " " <<
pix_to_y_point( d, apts[0].x, apts[0].y ) << " ";
for (i=1; i<pEmr->cpts; ) {
tmp_str << "\n\tC ";
for (j=0; j<3 && i<pEmr->cpts; j++,i++) {
tmp_str <<
pix_to_x_point( d, apts[i].x, apts[i].y ) << " " <<
pix_to_y_point( d, apts[i].x, apts[i].y ) << " ";
}
}
if (d->inpath) {
tmp_path << tmp_str.str().c_str();
}
else {
*(d->outsvg) += tmp_str.str().c_str();
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYGON16:
{
dbg_str << "<!-- EMR_POLYGON16 -->\n";
PEMRPOLYGON16 pEmr = (PEMRPOLYGON16) lpEMFR;
POINTS *apts = (POINTS *) pEmr->apts; // Bug in MinGW wingdi.h ?
SVGOStringStream tmp_poly;
unsigned int i;
unsigned int first = 0;
assert_empty_path(d, "EMR_POLYGON16");
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEANDFILLPATH);
*(d->outsvg) += "\n\td=\"";
// skip the first point?
tmp_poly << "\n\tM " <<
pix_to_x_point( d, apts[first].x, apts[first].y ) << " " <<
pix_to_y_point( d, apts[first].x, apts[first].y ) << " ";
for (i=first+1; i<pEmr->cpts; i++) {
tmp_poly << "\n\tL " <<
pix_to_x_point( d, apts[i].x, apts[i].y ) << " " <<
pix_to_y_point( d, apts[i].x, apts[i].y ) << " ";
}
*(d->outsvg) += tmp_poly.str().c_str();
*(d->outsvg) += " z \" /> \n";
break;
}
case EMR_POLYLINE16:
{
dbg_str << "<!-- EMR_POLYLINE16 -->\n";
EMRPOLYLINE16 *pEmr = (EMRPOLYLINE16 *) lpEMFR;
POINTS *apts = (POINTS *) pEmr->apts; // Bug in MinGW wingdi.h ?
DWORD i;
if (pEmr->cpts<2)
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYLINE16");
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEPATH);
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
pix_to_x_point( d, apts[0].x, apts[0].y ) << " " <<
pix_to_y_point( d, apts[0].x, apts[0].y ) << " ";
for (i=1; i<pEmr->cpts; i++) {
tmp_str <<
"\n\tL " <<
pix_to_x_point( d, apts[i].x, apts[i].y ) << " " <<
pix_to_y_point( d, apts[i].x, apts[i].y ) << " ";
}
if (d->inpath) {
tmp_path << tmp_str.str().c_str();
}
else {
*(d->outsvg) += tmp_str.str().c_str();
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYBEZIERTO16:
{
dbg_str << "<!-- EMR_POLYBEZIERTO16 -->\n";
PEMRPOLYBEZIERTO16 pEmr = (PEMRPOLYBEZIERTO16) lpEMFR;
POINTS *apts = (POINTS *) pEmr->apts; // Bug in MinGW wingdi.h ?
DWORD i,j;
if (d->path->empty()) {
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
for (i=0; i<pEmr->cpts;) {
tmp_path << "\n\tC ";
for (j=0; j<3 && i<pEmr->cpts; j++,i++) {
tmp_path <<
pix_to_x_point( d, apts[i].x, apts[i].y ) << " " <<
pix_to_y_point( d, apts[i].x, apts[i].y ) << " ";
}
}
break;
}
case EMR_POLYLINETO16:
{
dbg_str << "<!-- EMR_POLYLINETO16 -->\n";
PEMRPOLYLINETO16 pEmr = (PEMRPOLYLINETO16) lpEMFR;
POINTS *apts = (POINTS *) pEmr->apts; // Bug in MinGW wingdi.h ?
DWORD i;
if (d->path->empty()) {
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
for (i=0; i<pEmr->cpts;i++) {
tmp_path <<
"\n\tL " <<
pix_to_x_point( d, apts[i].x, apts[i].y ) << " " <<
pix_to_y_point( d, apts[i].x, apts[i].y ) << " ";
}
break;
}
case EMR_POLYPOLYLINE16:
case EMR_POLYPOLYGON16:
{
if (lpEMFR->iType == EMR_POLYPOLYLINE16)
dbg_str << "<!-- EMR_POLYPOLYLINE16 -->\n";
if (lpEMFR->iType == EMR_POLYPOLYGON16)
dbg_str << "<!-- EMR_POLYPOLYGON16 -->\n";
PEMRPOLYPOLYGON16 pEmr = (PEMRPOLYPOLYGON16) lpEMFR;
unsigned int n, i, j;
if (!d->inpath) {
assert_empty_path(d, lpEMFR->iType == EMR_POLYPOLYGON16 ? "EMR_POLYPOLYGON16" : "EMR_POLYPOLYLINE16");
*(d->outsvg) += " <path ";
output_style(d, lpEMFR->iType==EMR_POLYPOLYGON16 ? EMR_STROKEANDFILLPATH : EMR_STROKEPATH);
*(d->outsvg) += "\n\td=\"";
}
POINTS *apts = (POINTS *) &pEmr->aPolyCounts[pEmr->nPolys];
i = 0;
for (n=0; n<pEmr->nPolys && i<pEmr->cpts; n++) {
SVGOStringStream poly_path;
poly_path << "\n\tM " <<
pix_to_x_point( d, apts[i].x, apts[i].y ) << " " <<
pix_to_y_point( d, apts[i].x, apts[i].y ) << " ";
i++;
for (j=1; j<pEmr->aPolyCounts[n] && i<pEmr->cpts; j++) {
poly_path << "\n\tL " <<
pix_to_x_point( d, apts[i].x, apts[i].y ) << " " <<
pix_to_y_point( d, apts[i].x, apts[i].y ) << " ";
i++;
}
tmp_str << poly_path.str().c_str();
if (lpEMFR->iType == EMR_POLYPOLYGON16)
tmp_str << " z";
tmp_str << " \n";
}
if (d->inpath) {
tmp_path << tmp_str.str().c_str();
}
else {
*(d->outsvg) += tmp_str.str().c_str();
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYDRAW16:
dbg_str << "<!-- EMR_POLYDRAW16 -->\n";
break;
case EMR_CREATEMONOBRUSH:
dbg_str << "<!-- EMR_CREATEMONOBRUSH -->\n";
break;
case EMR_CREATEDIBPATTERNBRUSHPT:
{
dbg_str << "<!-- EMR_CREATEDIBPATTERNBRUSHPT -->\n";
PEMRCREATEDIBPATTERNBRUSHPT pEmr = (PEMRCREATEDIBPATTERNBRUSHPT) lpEMFR;
int index = pEmr->ihBrush;
EMRCREATEDIBPATTERNBRUSHPT *pBrush =
(EMRCREATEDIBPATTERNBRUSHPT *) malloc( sizeof(EMRCREATEDIBPATTERNBRUSHPT) );
insert_object(d, index, EMR_CREATEDIBPATTERNBRUSHPT, (ENHMETARECORD *) pBrush);
break;
}
case EMR_EXTCREATEPEN:
{
dbg_str << "<!-- EMR_EXTCREATEPEN -->\n";
PEMREXTCREATEPEN pEmr = (PEMREXTCREATEPEN) lpEMFR;
int index = pEmr->ihPen;
EMREXTCREATEPEN *pPen =
(EMREXTCREATEPEN *) malloc( sizeof(EMREXTCREATEPEN) +
sizeof(DWORD) * pEmr->elp.elpNumEntries );
pPen->ihPen = pEmr->ihPen;
pPen->offBmi = pEmr->offBmi;
pPen->cbBmi = pEmr->cbBmi;
pPen->offBits = pEmr->offBits;
pPen->cbBits = pEmr->cbBits;
pPen->elp = pEmr->elp;
for (unsigned int i=0; i<pEmr->elp.elpNumEntries; i++) {
pPen->elp.elpStyleEntry[i] = pEmr->elp.elpStyleEntry[i];
}
insert_object(d, index, EMR_EXTCREATEPEN, (ENHMETARECORD *) pPen);
break;
}
case EMR_POLYTEXTOUTA:
dbg_str << "<!-- EMR_POLYTEXTOUTA -->\n";
break;
case EMR_POLYTEXTOUTW:
dbg_str << "<!-- EMR_POLYTEXTOUTW -->\n";
break;
case EMR_SETICMMODE:
dbg_str << "<!-- EMR_SETICMMODE -->\n";
break;
case EMR_CREATECOLORSPACE:
dbg_str << "<!-- EMR_CREATECOLORSPACE -->\n";
break;
case EMR_SETCOLORSPACE:
dbg_str << "<!-- EMR_SETCOLORSPACE -->\n";
break;
case EMR_DELETECOLORSPACE:
dbg_str << "<!-- EMR_DELETECOLORSPACE -->\n";
break;
case EMR_GLSRECORD:
dbg_str << "<!-- EMR_GLSRECORD -->\n";
break;
case EMR_GLSBOUNDEDRECORD:
dbg_str << "<!-- EMR_GLSBOUNDEDRECORD -->\n";
break;
case EMR_PIXELFORMAT:
dbg_str << "<!-- EMR_PIXELFORMAT -->\n";
break;
default:
dbg_str << "<!-- EMR_??? -->\n";
break;
}
// *(d->outsvg) += dbg_str.str().c_str();
*(d->outsvg) += tmp_outsvg.str().c_str();
*(d->path) += tmp_path.str().c_str();
return 1;
}
static int CALLBACK
myMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, METARECORD * /*lpMFR*/, int /*nObj*/, LPARAM /*lpData*/)
{
g_warning("Unable to import Windows Meta File.\n");
return 0;
}
// Aldus Placeable Header ===================================================
// Since we are a 32bit app, we have to be sure this structure compiles to
// be identical to a 16 bit app's version. To do this, we use the #pragma
// to adjust packing, we use a WORD for the hmf handle, and a SMALL_RECT
// for the bbox rectangle.
#pragma pack( push )
#pragma pack( 2 )
typedef struct
{
DWORD dwKey;
WORD hmf;
SMALL_RECT bbox;
WORD wInch;
DWORD dwReserved;
WORD wCheckSum;
} APMHEADER, *PAPMHEADER;
#pragma pack( pop )
SPDocument *
EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
{
EMF_CALLBACK_DATA d;
memset(&d, 0, sizeof(d));
d.dc[0].worldTransform.eM11 = 1.0;
d.dc[0].worldTransform.eM12 = 0.0;
d.dc[0].worldTransform.eM21 = 0.0;
d.dc[0].worldTransform.eM22 = 1.0;
d.dc[0].worldTransform.eDx = 0.0;
d.dc[0].worldTransform.eDy = 0.0;
gsize bytesRead = 0;
gsize bytesWritten = 0;
GError* error = NULL;
gchar *local_fn =
g_filename_from_utf8( uri, -1, &bytesRead, &bytesWritten, &error );
if (local_fn == NULL) {
return NULL;
}
d.outsvg = new Glib::ustring("");
d.path = new Glib::ustring("");
d.outdef = new Glib::ustring("");
CHAR *ansi_uri = (CHAR *) local_fn;
gunichar2 *unicode_fn = g_utf8_to_utf16( local_fn, -1, NULL, NULL, NULL );
WCHAR *unicode_uri = (WCHAR *) unicode_fn;
DWORD filesize = 0;
HANDLE fp = NULL;
HMETAFILE hmf;
HENHMETAFILE hemf;
fp = CreateFileW(unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if ( fp != INVALID_HANDLE_VALUE ) {
filesize = GetFileSize(fp, NULL);
CloseHandle(fp);
}
// Try open as Enhanced Metafile
hemf = GetEnhMetaFileW(unicode_uri);
if (!hemf) {
// Try open as Windows Metafile
hmf = GetMetaFileW(unicode_uri);
METAFILEPICT mp;
HDC hDC;
if (!hmf) {
WCHAR szTemp[MAX_PATH];
DWORD dw = GetShortPathNameW( unicode_uri, szTemp, MAX_PATH );
if (dw) {
hmf = GetMetaFileW( szTemp );
}
}
if (hmf) {
DWORD nSize = GetMetaFileBitsEx( hmf, 0, NULL );
if (!nSize)
nSize = filesize;
if (nSize) {
BYTE *lpvData = new BYTE[nSize];
if (lpvData) {
DWORD dw = GetMetaFileBitsEx( hmf, nSize, lpvData );
if (dw) {
// Fill out a METAFILEPICT structure
mp.mm = MM_ANISOTROPIC;
mp.xExt = 1000;
mp.yExt = 1000;
mp.hMF = NULL;
// Get a reference DC
hDC = GetDC( NULL );
// Make an enhanced metafile from the windows metafile
hemf = SetWinMetaFileBits( nSize, lpvData, hDC, &mp );
// Clean up
ReleaseDC( NULL, hDC );
DeleteMetaFile( hmf );
hmf = NULL;
}
else {
// EnumMetaFile
}
delete[] lpvData;
}
else {
DeleteMetaFile( hmf );
hmf = NULL;
}
}
else {
DeleteMetaFile( hmf );
hmf = NULL;
}
}
else {
// Try open as Aldus Placeable Metafile
HANDLE hFile;
hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if (hFile != INVALID_HANDLE_VALUE) {
DWORD nSize = GetFileSize( hFile, NULL );
if (nSize) {
BYTE *lpvData = new BYTE[nSize];
if (lpvData) {
DWORD dw = ReadFile( hFile, lpvData, nSize, &nSize, NULL );
if (dw) {
if ( ((PAPMHEADER)lpvData)->dwKey == 0x9ac6cdd7l ) {
// Fill out a METAFILEPICT structure
mp.mm = MM_ANISOTROPIC;
mp.xExt = ((PAPMHEADER)lpvData)->bbox.Right - ((PAPMHEADER)lpvData)->bbox.Left;
mp.xExt = ( mp.xExt * 2540l ) / (DWORD)(((PAPMHEADER)lpvData)->wInch);
mp.yExt = ((PAPMHEADER)lpvData)->bbox.Bottom - ((PAPMHEADER)lpvData)->bbox.Top;
mp.yExt = ( mp.yExt * 2540l ) / (DWORD)(((PAPMHEADER)lpvData)->wInch);
mp.hMF = NULL;
// Get a reference DC
hDC = GetDC( NULL );
// Create an enhanced metafile from the bits
hemf = SetWinMetaFileBits( nSize, lpvData+sizeof(APMHEADER), hDC, &mp );
// Clean up
ReleaseDC( NULL, hDC );
}
}
delete[] lpvData;
}
}
CloseHandle( hFile );
}
}
}
if ((!hemf && !hmf) || !d.outsvg || !d.path) {
if (d.outsvg)
delete d.outsvg;
if (d.path)
delete d.path;
if (d.outdef)
delete d.outdef;
if (local_fn)
g_free(local_fn);
if (unicode_fn)
g_free(unicode_fn);
if (hemf)
DeleteEnhMetaFile(hemf);
if (hmf)
DeleteMetaFile(hmf);
return NULL;
}
d.pDesc = NULL;
if (hemf) {
DWORD dwNeeded = GetEnhMetaFileDescriptionA( hemf, 0, NULL );
if ( dwNeeded > 0 ) {
d.pDesc = (CHAR *) malloc( dwNeeded + 1 );
if ( GetEnhMetaFileDescription( hemf, dwNeeded, d.pDesc ) == 0 )
lstrcpy( d.pDesc, "" );
if ( lstrlen( d.pDesc ) > 1 )
d.pDesc[lstrlen(d.pDesc)] = '#';
}
// This ugly reinterpret_cast is to prevent old versions of gcc from whining about a mismatch in the const-ness of the arguments
EnumEnhMetaFile(NULL, hemf, reinterpret_cast<ENHMFENUMPROC>(myEnhMetaFileProc), (LPVOID) &d, NULL);
DeleteEnhMetaFile(hemf);
}
else {
EnumMetaFile(NULL, hmf, myMetaFileProc, (LPARAM) &d);
DeleteMetaFile(hmf);
}
if (d.pDesc)
free( d.pDesc );
// std::cout << "SVG Output: " << std::endl << *(d.outsvg) << std::endl;
SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg->c_str(), strlen(d.outsvg->c_str()), TRUE);
delete d.outsvg;
delete d.path;
delete d.outdef;
if (d.emf_obj) {
int i;
for (i=0; i<d.n_obj; i++)
delete_object(&d, i);
delete[] d.emf_obj;
}
if (d.dc[0].style.stroke_dash.dash)
delete[] d.dc[0].style.stroke_dash.dash;
if (local_fn)
g_free(local_fn);
if (unicode_fn)
g_free(unicode_fn);
return doc;
}
void
EmfWin32::init (void)
{
/* EMF in */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("EMF Input") "</name>\n"
"<id>org.inkscape.input.emf.win32</id>\n"
"<input>\n"
"<extension>.emf</extension>\n"
"<mimetype>image/x-emf</mimetype>\n"
"<filetypename>" N_("Enhanced Metafiles (*.emf)") "</filetypename>\n"
"<filetypetooltip>" N_("Enhanced Metafiles") "</filetypetooltip>\n"
"<output_extension>org.inkscape.output.emf.win32</output_extension>\n"
"</input>\n"
"</inkscape-extension>", new EmfWin32());
/* WMF in */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("WMF Input") "</name>\n"
"<id>org.inkscape.input.wmf.win32</id>\n"
"<input>\n"
"<extension>.wmf</extension>\n"
"<mimetype>image/x-wmf</mimetype>\n"
"<filetypename>" N_("Windows Metafiles (*.wmf)") "</filetypename>\n"
"<filetypetooltip>" N_("Windows Metafiles") "</filetypetooltip>\n"
"<output_extension>org.inkscape.output.emf.win32</output_extension>\n"
"</input>\n"
"</inkscape-extension>", new EmfWin32());
/* EMF out */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("EMF Output") "</name>\n"
"<id>org.inkscape.output.emf.win32</id>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">true</param>\n"
"<output>\n"
"<extension>.emf</extension>\n"
"<mimetype>image/x-emf</mimetype>\n"
"<filetypename>" N_("Enhanced Metafile (*.emf)") "</filetypename>\n"
"<filetypetooltip>" N_("Enhanced Metafile") "</filetypetooltip>\n"
"</output>\n"
"</inkscape-extension>", new EmfWin32());
return;
}
} } } /* namespace Inkscape, Extension, Implementation */
#endif /* WIN32 */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|
Sean3Don/inkscape
|
src/extension/internal/emf-win32-inout.cpp
|
C++
|
gpl-2.0
| 90,779 |
<?php
/**
* Kunena Component
* @package Kunena.Framework
* @subpackage Controller
*
* @copyright (C) 2008 - 2016 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.org
**/
defined ( '_JEXEC' ) or die ();
/**
* @see JController in Joomla! 3.0
*/
abstract class KunenaControllerBase implements Serializable
{
/**
* The application object.
*
* @var JApplicationBase|JSite|JAdministrator
*/
protected $app;
/**
* The input object.
*
* @var JInput
*/
protected $input;
/**
* Options object.
*
* @var JRegistry
* @since K4.0
*/
protected $options = null;
/**
* Instantiate the controller.
*
* @param JInput $input The input object.
* @param JApplicationBase $app The application object.
* @param JRegistry|array $options Array / JRegistry object with the options to load.
*/
public function __construct(JInput $input = null, $app = null, $options = null)
{
// Setup dependencies.
$this->app = isset($app) ? $app : $this->loadApplication();
$this->input = isset($input) ? $input : $this->loadInput();
if ($options)
{
$this->setOptions($options);
}
}
/**
* Set the options.
*
* @param mixed $options Array / JRegistry object with the options to load.
*
* @return KunenaControllerBase Instance of $this to allow chaining.
*
* @since K4.0
*/
public function setOptions($options = null)
{
// Received JRegistry
if ($options instanceof JRegistry)
{
$this->options = $options;
}
// Received array
elseif (is_array($options))
{
$this->options = new JRegistry($options);
}
else
{
$this->options = new JRegistry;
}
return $this;
}
/**
* Get the options.
*
* @return JRegistry Object with the options.
*
* @since K4.0
*/
public function getOptions()
{
// Always return a JRegistry instance
if (!($this->options instanceof JRegistry))
{
$this->resetOptions();
}
return $this->options;
}
/**
* Function to empty all the options.
*
* @return KunenaControllerBase Instance of $this to allow chaining.
*
* @since K4.0
*/
public function resetOptions()
{
return $this->setOptions(null);
}
/**
* Execute the controller.
*
* @return mixed
*
* @throws LogicException
* @throws RuntimeException
*/
abstract public function execute();
/**
* Get the application object.
*
* @return JApplicationBase The application object.
*/
public function getApplication()
{
return $this->app;
}
/**
* Get the input object.
*
* @return JInput The input object.
*/
public function getInput()
{
return $this->input;
}
/**
* Serialize the controller.
*
* @return string The serialized controller.
*/
public function serialize()
{
return serialize(array($this->input, $this->options));
}
/**
* Unserialize the controller.
*
* @param string $input The serialized controller.
*
* @return JController Supports chaining.
*
* @throws UnexpectedValueException if input is not the right class.
*/
public function unserialize($input)
{
// Setup dependencies.
$this->app = $this->loadApplication();
// Unserialize the input and options.
list ($this->input, $this->options) = unserialize($input);
if (!($this->input instanceof JInput))
{
throw new UnexpectedValueException(sprintf('%s::unserialize would not accept a `%s`.', get_class($this), gettype($this->input)));
}
return $this;
}
/**
* Load the application object.
*
* @return JApplicationBase The application object.
*/
protected function loadApplication()
{
return JFactory::getApplication();
}
/**
* Load the input object.
*
* @return JInput The input object.
*/
protected function loadInput()
{
return $this->app->input;
}
}
|
githubupttik/upttik
|
libraries/kunena/controller/base.php
|
PHP
|
gpl-2.0
| 3,886 |
.videoBackdrop {
/* Allows popups to be closed, because their z-index is 1099 */
z-index: 1098;
position: fixed;
background-color: transparent;
background-color: rgba(0, 0, 0, 0.6);
top: 0;
right: 0;
bottom: 0;
left: 0;
}
#videoPlayer {
z-index: 99997;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #222;
color: #fff;
}
.itemVideo {
background-color: #000;
width: 100%;
height: auto;
}
.videoCanvas {
background-color: #000;
position: fixed;
top: 200px;
bottom: 200px;
left: 200px;
right: 200px;
}
.videoControls {
position: fixed;
left: 0;
bottom: 0;
right: 0;
z-index: 99998;
text-align: center;
}
.videoControls > div {
background-color: rgba(0, 0, 0, .7);
}
.videoControlButtons {
padding: 0 .5em;
}
.videoTopControls {
padding: 0 1em;
background-color: rgba(0, 0, 0, .5);
position: absolute;
left: 0;
top: 0;
right: 0;
z-index: 99998;
}
.videoAdvancedControls {
text-align: right;
vertical-align: top;
padding-top: .5em;
}
.videoAdvancedControls iron-icon {
width: 32px;
height: 32px;
}
.nowPlayingInfo {
text-align: center;
padding: 1.5em 1em 2em 1em;
}
#videoPlayer .nowPlayingImage img {
height: auto !important;
max-width: 180px;
max-height: 220px;
}
#videoPlayer .nowPlayingTabs {
margin: 0 0 0 1em;
overflow: hidden;
white-space: normal;
text-overflow: ellipsis;
text-align: left;
vertical-align: top;
color: #eee;
display: inline-block;
width: 70%;
font-weight: normal;
font-size: 14px;
}
@media all and (max-width: 1200px) {
#videoPlayer .nowPlayingTabs {
font-size: 13px;
}
}
.nowPlayingTabButtons {
margin-bottom: 1.25em;
}
.nowPlayingTabButton {
display: inline-block;
font-size: 18px;
text-transform: uppercase;
color: #ddd !important;
font-weight: 400 !important;
text-decoration: none;
}
.nowPlayingTabButton + .nowPlayingTabButton {
padding-left: 1.5em;
}
.nowPlayingTabButton:not(.selectedNowPlayingTabButton):hover {
color: white !important;
}
.selectedNowPlayingTabButton {
color: #2ad !important;
}
.nowPlayingTab {
overflow-y: hidden;
overflow-x: auto;
}
#videoPlayer .nowPlayingText {
font-weight: normal;
margin: 0 0 0 1em;
max-width: initial;
overflow: hidden;
white-space: normal;
text-overflow: ellipsis;
text-align: left;
vertical-align: top;
position: static;
color: #eee;
}
.videoNowPlayingName {
font-size: 18px;
}
.videoNowPlayingOverview, .videoNowPlayingRating {
margin: 1em 0;
}
.videoTopControlsLogo {
float: left;
/* Matches .mediaButton */
padding: 10px 0;
}
.videoTopControlsLogo img {
max-height: 42px;
max-width: 200px;
}
/* Fullscreen
***************************************/
#videoPlayer, .itemVideo {
position: fixed !important;
top: 0 !important;
bottom: 0 !important;
right: 0 !important;
left: 0 !important;
width: 100% !important;
height: 100% !important;
border: 0 !important;
margin: 0 !important;
max-width: 100%;
max-height: 100%;
}
/* Hack for safari because it doesn't allow clickable content over the video surface. */
/*.itemVideo { (;top: 9%!important;height: 91% !important;); }
.itemVideo { [;top: 9%!important;height: 91% !important;]; }*/
#videoPlayer .inactive {
display: none !important;
}
.idlePlayer video {
cursor: none;
}
/****************************************/
@media all and (max-width: 1200px), all and (max-height: 720px) {
.videoControls .currentTime {
margin-right: 0;
min-width: 120px;
}
}
@media all and (max-width: 1400px), all and (max-height: 900px) {
.mediaButton.infoButton {
display: none !important;
}
}
@media all and (max-width: 555px) {
#mediaPlayer .videoControls .previousTrackButton, #mediaPlayer .videoControls .nextTrackButton {
display: none !important;
}
.videoTopControlsLogo {
display: none !important;
}
}
@media all and (min-width: 1400px) {
.nowPlayingInfo {
padding-bottom: 0;
}
#videoPlayer .nowPlayingImage img {
height: auto !important;
max-width: 360px;
max-height: 220px;
}
}
/****************************************/
.status {
position: absolute;
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -75px;
width: 150px;
height: 150px;
z-index: 99999;
}
#play {
background-image: url(images/media/play.png);
opacity: 0;
display: none;
}
#pause {
background-image: url(images/media/pause.png);
opacity: 0;
display: none;
}
.fadeOut {
animation-name: fadeOut;
-webkit-animation-name: fadeOut;
animation-duration: .25s;
-webkit-animation-duration: .25s;
animation-timing-function: ease-in-out;
-webkit-animation-timing-function: ease-in-out;
visibility: visible !important;
}
@keyframes fadeOut {
0% {
transform: scale(.25);
opacity: 0.7;
}
60% {
transform: scale(.5);
opacity: 0.5;
}
80% {
transform: scale(.75);
opacity: 0.3;
}
100% {
transform: scale(1);
opacity: 0;
}
}
@-webkit-keyframes fadeOut {
0% {
-webkit-transform: scale(.25);
opacity: 0.7;
}
60% {
-webkit-transform: scale(.5);
opacity: 0.5;
}
80% {
-webkit-transform: scale(.75);
opacity: 0.3;
}
100% {
-webkit-transform: scale(1);
opacity: 0;
}
}
|
hmflash/Emby
|
MediaBrowser.WebDashboard/dashboard-ui/css/mediaplayer-video.css
|
CSS
|
gpl-2.0
| 5,820 |
/* Handle errors.
Copyright (C) 2000-2015 Free Software Foundation, Inc.
Contributed by Andy Vaught & Niels Kristian Bech Jensen
This file is part of GCC.
GCC 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, or (at your option) any later
version.
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Handle the inevitable errors. A major catch here is that things
flagged as errors in one match subroutine can conceivably be legal
elsewhere. This means that error messages are recorded and saved
for possible use later. If a line does not match a legal
construction, then the saved error message is reported. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "options.h"
#include "gfortran.h"
#include "diagnostic.h"
#include "diagnostic-color.h"
#include "tree-diagnostic.h" /* tree_diagnostics_defaults */
#include <new> /* For placement-new */
static int suppress_errors = 0;
static bool warnings_not_errors = false;
static int terminal_width;
/* True if the error/warnings should be buffered. */
static bool buffered_p;
static gfc_error_buffer error_buffer;
/* These are always buffered buffers (.flush_p == false) to be used by
the pretty-printer. */
static output_buffer *pp_error_buffer, *pp_warning_buffer;
static int warningcount_buffered, werrorcount_buffered;
/* Return true if there output_buffer is empty. */
static bool
gfc_output_buffer_empty_p (const output_buffer * buf)
{
return output_buffer_last_position_in_text (buf) == NULL;
}
/* Go one level deeper suppressing errors. */
void
gfc_push_suppress_errors (void)
{
gcc_assert (suppress_errors >= 0);
++suppress_errors;
}
static void
gfc_error (const char *gmsgid, va_list ap) ATTRIBUTE_GCC_GFC(1,0);
static bool
gfc_warning (int opt, const char *gmsgid, va_list ap) ATTRIBUTE_GCC_GFC(2,0);
/* Leave one level of error suppressing. */
void
gfc_pop_suppress_errors (void)
{
gcc_assert (suppress_errors > 0);
--suppress_errors;
}
/* Determine terminal width (for trimming source lines in output). */
static int
gfc_get_terminal_width (void)
{
return isatty (STDERR_FILENO) ? get_terminal_width () : INT_MAX;
}
/* Per-file error initialization. */
void
gfc_error_init_1 (void)
{
terminal_width = gfc_get_terminal_width ();
gfc_buffer_error (false);
}
/* Set the flag for buffering errors or not. */
void
gfc_buffer_error (bool flag)
{
buffered_p = flag;
}
/* Add a single character to the error buffer or output depending on
buffered_p. */
static void
error_char (char)
{
/* FIXME: Unused function to be removed in a subsequent patch. */
}
/* Copy a string to wherever it needs to go. */
static void
error_string (const char *p)
{
while (*p)
error_char (*p++);
}
/* Print a formatted integer to the error buffer or output. */
#define IBUF_LEN 60
static void
error_uinteger (unsigned long int i)
{
char *p, int_buf[IBUF_LEN];
p = int_buf + IBUF_LEN - 1;
*p-- = '\0';
if (i == 0)
*p-- = '0';
while (i > 0)
{
*p-- = i % 10 + '0';
i = i / 10;
}
error_string (p + 1);
}
static void
error_integer (long int i)
{
unsigned long int u;
if (i < 0)
{
u = (unsigned long int) -i;
error_char ('-');
}
else
u = i;
error_uinteger (u);
}
static size_t
gfc_widechar_display_length (gfc_char_t c)
{
if (gfc_wide_is_printable (c) || c == '\t')
/* Printable ASCII character, or tabulation (output as a space). */
return 1;
else if (c < ((gfc_char_t) 1 << 8))
/* Displayed as \x?? */
return 4;
else if (c < ((gfc_char_t) 1 << 16))
/* Displayed as \u???? */
return 6;
else
/* Displayed as \U???????? */
return 10;
}
/* Length of the ASCII representation of the wide string, escaping wide
characters as print_wide_char_into_buffer() does. */
static size_t
gfc_wide_display_length (const gfc_char_t *str)
{
size_t i, len;
for (i = 0, len = 0; str[i]; i++)
len += gfc_widechar_display_length (str[i]);
return len;
}
static int
print_wide_char_into_buffer (gfc_char_t c, char *buf)
{
static const char xdigit[16] = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
if (gfc_wide_is_printable (c) || c == '\t')
{
buf[1] = '\0';
/* Tabulation is output as a space. */
buf[0] = (unsigned char) (c == '\t' ? ' ' : c);
return 1;
}
else if (c < ((gfc_char_t) 1 << 8))
{
buf[4] = '\0';
buf[3] = xdigit[c & 0x0F];
c = c >> 4;
buf[2] = xdigit[c & 0x0F];
buf[1] = 'x';
buf[0] = '\\';
return 4;
}
else if (c < ((gfc_char_t) 1 << 16))
{
buf[6] = '\0';
buf[5] = xdigit[c & 0x0F];
c = c >> 4;
buf[4] = xdigit[c & 0x0F];
c = c >> 4;
buf[3] = xdigit[c & 0x0F];
c = c >> 4;
buf[2] = xdigit[c & 0x0F];
buf[1] = 'u';
buf[0] = '\\';
return 6;
}
else
{
buf[10] = '\0';
buf[9] = xdigit[c & 0x0F];
c = c >> 4;
buf[8] = xdigit[c & 0x0F];
c = c >> 4;
buf[7] = xdigit[c & 0x0F];
c = c >> 4;
buf[6] = xdigit[c & 0x0F];
c = c >> 4;
buf[5] = xdigit[c & 0x0F];
c = c >> 4;
buf[4] = xdigit[c & 0x0F];
c = c >> 4;
buf[3] = xdigit[c & 0x0F];
c = c >> 4;
buf[2] = xdigit[c & 0x0F];
buf[1] = 'U';
buf[0] = '\\';
return 10;
}
}
static char wide_char_print_buffer[11];
const char *
gfc_print_wide_char (gfc_char_t c)
{
print_wide_char_into_buffer (c, wide_char_print_buffer);
return wide_char_print_buffer;
}
/* Show the file, where it was included, and the source line, give a
locus. Calls error_printf() recursively, but the recursion is at
most one level deep. */
static void error_printf (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
static void
show_locus (locus *loc, int c1, int c2)
{
gfc_linebuf *lb;
gfc_file *f;
gfc_char_t *p;
int i, offset, cmax;
/* TODO: Either limit the total length and number of included files
displayed or add buffering of arbitrary number of characters in
error messages. */
/* Write out the error header line, giving the source file and error
location (in GNU standard "[file]:[line].[column]:" format),
followed by an "included by" stack and a blank line. This header
format is matched by a testsuite parser defined in
lib/gfortran-dg.exp. */
lb = loc->lb;
f = lb->file;
error_string (f->filename);
error_char (':');
error_integer (LOCATION_LINE (lb->location));
if ((c1 > 0) || (c2 > 0))
error_char ('.');
if (c1 > 0)
error_integer (c1);
if ((c1 > 0) && (c2 > 0))
error_char ('-');
if (c2 > 0)
error_integer (c2);
error_char (':');
error_char ('\n');
for (;;)
{
i = f->inclusion_line;
f = f->up;
if (f == NULL) break;
error_printf (" Included at %s:%d:", f->filename, i);
}
error_char ('\n');
/* Calculate an appropriate horizontal offset of the source line in
order to get the error locus within the visible portion of the
line. Note that if the margin of 5 here is changed, the
corresponding margin of 10 in show_loci should be changed. */
offset = 0;
/* If the two loci would appear in the same column, we shift
'2' one column to the right, so as to print '12' rather than
just '1'. We do this here so it will be accounted for in the
margin calculations. */
if (c1 == c2)
c2 += 1;
cmax = (c1 < c2) ? c2 : c1;
if (cmax > terminal_width - 5)
offset = cmax - terminal_width + 5;
/* Show the line itself, taking care not to print more than what can
show up on the terminal. Tabs are converted to spaces, and
nonprintable characters are converted to a "\xNN" sequence. */
p = &(lb->line[offset]);
i = gfc_wide_display_length (p);
if (i > terminal_width)
i = terminal_width - 1;
while (i > 0)
{
static char buffer[11];
i -= print_wide_char_into_buffer (*p++, buffer);
error_string (buffer);
}
error_char ('\n');
/* Show the '1' and/or '2' corresponding to the column of the error
locus. Note that a value of -1 for c1 or c2 will simply cause
the relevant number not to be printed. */
c1 -= offset;
c2 -= offset;
cmax -= offset;
p = &(lb->line[offset]);
for (i = 0; i < cmax; i++)
{
int spaces, j;
spaces = gfc_widechar_display_length (*p++);
if (i == c1)
error_char ('1'), spaces--;
else if (i == c2)
error_char ('2'), spaces--;
for (j = 0; j < spaces; j++)
error_char (' ');
}
if (i == c1)
error_char ('1');
else if (i == c2)
error_char ('2');
error_char ('\n');
}
/* As part of printing an error, we show the source lines that caused
the problem. We show at least one, and possibly two loci; the two
loci may or may not be on the same source line. */
static void
show_loci (locus *l1, locus *l2)
{
int m, c1, c2;
if (l1 == NULL || l1->lb == NULL)
{
error_printf ("<During initialization>\n");
return;
}
/* While calculating parameters for printing the loci, we consider possible
reasons for printing one per line. If appropriate, print the loci
individually; otherwise we print them both on the same line. */
c1 = l1->nextc - l1->lb->line;
if (l2 == NULL)
{
show_locus (l1, c1, -1);
return;
}
c2 = l2->nextc - l2->lb->line;
if (c1 < c2)
m = c2 - c1;
else
m = c1 - c2;
/* Note that the margin value of 10 here needs to be less than the
margin of 5 used in the calculation of offset in show_locus. */
if (l1->lb != l2->lb || m > terminal_width - 10)
{
show_locus (l1, c1, -1);
show_locus (l2, -1, c2);
return;
}
show_locus (l1, c1, c2);
return;
}
/* Workhorse for the error printing subroutines. This subroutine is
inspired by g77's error handling and is similar to printf() with
the following %-codes:
%c Character, %d or %i Integer, %s String, %% Percent
%L Takes locus argument
%C Current locus (no argument)
If a locus pointer is given, the actual source line is printed out
and the column is indicated. Since we want the error message at
the bottom of any source file information, we must scan the
argument list twice -- once to determine whether the loci are
present and record this for printing, and once to print the error
message after and loci have been printed. A maximum of two locus
arguments are permitted.
This function is also called (recursively) by show_locus in the
case of included files; however, as show_locus does not resupply
any loci, the recursion is at most one level deep. */
#define MAX_ARGS 10
static void ATTRIBUTE_GCC_GFC(2,0)
error_print (const char *type, const char *format0, va_list argp)
{
enum { TYPE_CURRENTLOC, TYPE_LOCUS, TYPE_INTEGER, TYPE_UINTEGER,
TYPE_LONGINT, TYPE_ULONGINT, TYPE_CHAR, TYPE_STRING,
NOTYPE };
struct
{
int type;
int pos;
union
{
int intval;
unsigned int uintval;
long int longintval;
unsigned long int ulongintval;
char charval;
const char * stringval;
} u;
} arg[MAX_ARGS], spec[MAX_ARGS];
/* spec is the array of specifiers, in the same order as they
appear in the format string. arg is the array of arguments,
in the same order as they appear in the va_list. */
char c;
int i, n, have_l1, pos, maxpos;
locus *l1, *l2, *loc;
const char *format;
loc = l1 = l2 = NULL;
have_l1 = 0;
pos = -1;
maxpos = -1;
n = 0;
format = format0;
for (i = 0; i < MAX_ARGS; i++)
{
arg[i].type = NOTYPE;
spec[i].pos = -1;
}
/* First parse the format string for position specifiers. */
while (*format)
{
c = *format++;
if (c != '%')
continue;
if (*format == '%')
{
format++;
continue;
}
if (ISDIGIT (*format))
{
/* This is a position specifier. For example, the number
12 in the format string "%12$d", which specifies the third
argument of the va_list, formatted in %d format.
For details, see "man 3 printf". */
pos = atoi(format) - 1;
gcc_assert (pos >= 0);
while (ISDIGIT(*format))
format++;
gcc_assert (*format == '$');
format++;
}
else
pos++;
c = *format++;
if (pos > maxpos)
maxpos = pos;
switch (c)
{
case 'C':
arg[pos].type = TYPE_CURRENTLOC;
break;
case 'L':
arg[pos].type = TYPE_LOCUS;
break;
case 'd':
case 'i':
arg[pos].type = TYPE_INTEGER;
break;
case 'u':
arg[pos].type = TYPE_UINTEGER;
break;
case 'l':
c = *format++;
if (c == 'u')
arg[pos].type = TYPE_ULONGINT;
else if (c == 'i' || c == 'd')
arg[pos].type = TYPE_LONGINT;
else
gcc_unreachable ();
break;
case 'c':
arg[pos].type = TYPE_CHAR;
break;
case 's':
arg[pos].type = TYPE_STRING;
break;
default:
gcc_unreachable ();
}
spec[n++].pos = pos;
}
/* Then convert the values for each %-style argument. */
for (pos = 0; pos <= maxpos; pos++)
{
gcc_assert (arg[pos].type != NOTYPE);
switch (arg[pos].type)
{
case TYPE_CURRENTLOC:
loc = &gfc_current_locus;
/* Fall through. */
case TYPE_LOCUS:
if (arg[pos].type == TYPE_LOCUS)
loc = va_arg (argp, locus *);
if (have_l1)
{
l2 = loc;
arg[pos].u.stringval = "(2)";
}
else
{
l1 = loc;
have_l1 = 1;
arg[pos].u.stringval = "(1)";
}
break;
case TYPE_INTEGER:
arg[pos].u.intval = va_arg (argp, int);
break;
case TYPE_UINTEGER:
arg[pos].u.uintval = va_arg (argp, unsigned int);
break;
case TYPE_LONGINT:
arg[pos].u.longintval = va_arg (argp, long int);
break;
case TYPE_ULONGINT:
arg[pos].u.ulongintval = va_arg (argp, unsigned long int);
break;
case TYPE_CHAR:
arg[pos].u.charval = (char) va_arg (argp, int);
break;
case TYPE_STRING:
arg[pos].u.stringval = (const char *) va_arg (argp, char *);
break;
default:
gcc_unreachable ();
}
}
for (n = 0; spec[n].pos >= 0; n++)
spec[n].u = arg[spec[n].pos].u;
/* Show the current loci if we have to. */
if (have_l1)
show_loci (l1, l2);
if (*type)
{
error_string (type);
error_char (' ');
}
have_l1 = 0;
format = format0;
n = 0;
for (; *format; format++)
{
if (*format != '%')
{
error_char (*format);
continue;
}
format++;
if (ISDIGIT (*format))
{
/* This is a position specifier. See comment above. */
while (ISDIGIT (*format))
format++;
/* Skip over the dollar sign. */
format++;
}
switch (*format)
{
case '%':
error_char ('%');
break;
case 'c':
error_char (spec[n++].u.charval);
break;
case 's':
case 'C': /* Current locus */
case 'L': /* Specified locus */
error_string (spec[n++].u.stringval);
break;
case 'd':
case 'i':
error_integer (spec[n++].u.intval);
break;
case 'u':
error_uinteger (spec[n++].u.uintval);
break;
case 'l':
format++;
if (*format == 'u')
error_uinteger (spec[n++].u.ulongintval);
else
error_integer (spec[n++].u.longintval);
break;
}
}
error_char ('\n');
}
/* Wrapper for error_print(). */
static void
error_printf (const char *gmsgid, ...)
{
va_list argp;
va_start (argp, gmsgid);
error_print ("", _(gmsgid), argp);
va_end (argp);
}
/* Clear any output buffered in a pretty-print output_buffer. */
static void
gfc_clear_pp_buffer (output_buffer *this_buffer)
{
pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer;
pp->buffer = this_buffer;
pp_clear_output_area (pp);
pp->buffer = tmp_buffer;
/* We need to reset last_location, otherwise we may skip caret lines
when we actually give a diagnostic. */
global_dc->last_location = UNKNOWN_LOCATION;
}
/* This is just a helper function to avoid duplicating the logic of
gfc_warning. */
static bool
gfc_warning (int opt, const char *gmsgid, va_list ap)
{
va_list argp;
va_copy (argp, ap);
diagnostic_info diagnostic;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
bool fatal_errors = global_dc->fatal_errors;
pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer;
gfc_clear_pp_buffer (pp_warning_buffer);
if (buffered_p)
{
pp->buffer = pp_warning_buffer;
global_dc->fatal_errors = false;
/* To prevent -fmax-errors= triggering. */
--werrorcount;
}
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
DK_WARNING);
diagnostic.option_index = opt;
bool ret = report_diagnostic (&diagnostic);
if (buffered_p)
{
pp->buffer = tmp_buffer;
global_dc->fatal_errors = fatal_errors;
warningcount_buffered = 0;
werrorcount_buffered = 0;
/* Undo the above --werrorcount if not Werror, otherwise
werrorcount is correct already. */
if (!ret)
++werrorcount;
else if (diagnostic.kind == DK_ERROR)
++werrorcount_buffered;
else
++werrorcount, --warningcount, ++warningcount_buffered;
}
va_end (argp);
return ret;
}
/* Issue a warning. */
bool
gfc_warning (int opt, const char *gmsgid, ...)
{
va_list argp;
va_start (argp, gmsgid);
bool ret = gfc_warning (opt, gmsgid, argp);
va_end (argp);
return ret;
}
/* Whether, for a feature included in a given standard set (GFC_STD_*),
we should issue an error or a warning, or be quiet. */
notification
gfc_notification_std (int std)
{
bool warning;
warning = ((gfc_option.warn_std & std) != 0) && !inhibit_warnings;
if ((gfc_option.allow_std & std) != 0 && !warning)
return SILENT;
return warning ? WARNING : ERROR;
}
/* Possibly issue a warning/error about use of a nonstandard (or deleted)
feature. An error/warning will be issued if the currently selected
standard does not contain the requested bits. Return false if
an error is generated. */
bool
gfc_notify_std (int std, const char *gmsgid, ...)
{
va_list argp;
bool warning;
const char *msg, *msg2;
char *buffer;
warning = ((gfc_option.warn_std & std) != 0) && !inhibit_warnings;
if ((gfc_option.allow_std & std) != 0 && !warning)
return true;
if (suppress_errors)
return warning ? true : false;
switch (std)
{
case GFC_STD_F2008_TS:
msg = "TS 29113/TS 18508:";
break;
case GFC_STD_F2008_OBS:
msg = _("Fortran 2008 obsolescent feature:");
break;
case GFC_STD_F2008:
msg = "Fortran 2008:";
break;
case GFC_STD_F2003:
msg = "Fortran 2003:";
break;
case GFC_STD_GNU:
msg = _("GNU Extension:");
break;
case GFC_STD_LEGACY:
msg = _("Legacy Extension:");
break;
case GFC_STD_F95_OBS:
msg = _("Obsolescent feature:");
break;
case GFC_STD_F95_DEL:
msg = _("Deleted feature:");
break;
default:
gcc_unreachable ();
}
msg2 = _(gmsgid);
buffer = (char *) alloca (strlen (msg) + strlen (msg2) + 2);
strcpy (buffer, msg);
strcat (buffer, " ");
strcat (buffer, msg2);
va_start (argp, gmsgid);
if (warning)
gfc_warning (0, buffer, argp);
else
gfc_error (buffer, argp);
va_end (argp);
return (warning && !warnings_are_errors) ? true : false;
}
/* Called from output_format -- during diagnostic message processing
to handle Fortran specific format specifiers with the following meanings:
%C Current locus (no argument)
%L Takes locus argument
*/
static bool
gfc_format_decoder (pretty_printer *pp,
text_info *text, const char *spec,
int precision ATTRIBUTE_UNUSED, bool wide ATTRIBUTE_UNUSED,
bool plus ATTRIBUTE_UNUSED, bool hash ATTRIBUTE_UNUSED)
{
switch (*spec)
{
case 'C':
case 'L':
{
static const char *result[2] = { "(1)", "(2)" };
locus *loc;
if (*spec == 'C')
loc = &gfc_current_locus;
else
loc = va_arg (*text->args_ptr, locus *);
gcc_assert (loc->nextc - loc->lb->line >= 0);
unsigned int offset = loc->nextc - loc->lb->line;
/* If location[0] != UNKNOWN_LOCATION means that we already
processed one of %C/%L. */
int loc_num = text->get_location (0) == UNKNOWN_LOCATION ? 0 : 1;
location_t src_loc
= linemap_position_for_loc_and_offset (line_table,
loc->lb->location,
offset);
text->set_location (loc_num, src_loc, true);
pp_string (pp, result[loc_num]);
return true;
}
default:
return false;
}
}
/* Return a malloc'd string describing the kind of diagnostic. The
caller is responsible for freeing the memory. */
static char *
gfc_diagnostic_build_kind_prefix (diagnostic_context *context,
const diagnostic_info *diagnostic)
{
static const char *const diagnostic_kind_text[] = {
#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (T),
#include "gfc-diagnostic.def"
#undef DEFINE_DIAGNOSTIC_KIND
"must-not-happen"
};
static const char *const diagnostic_kind_color[] = {
#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (C),
#include "gfc-diagnostic.def"
#undef DEFINE_DIAGNOSTIC_KIND
NULL
};
gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND);
const char *text = _(diagnostic_kind_text[diagnostic->kind]);
const char *text_cs = "", *text_ce = "";
pretty_printer *pp = context->printer;
if (diagnostic_kind_color[diagnostic->kind])
{
text_cs = colorize_start (pp_show_color (pp),
diagnostic_kind_color[diagnostic->kind]);
text_ce = colorize_stop (pp_show_color (pp));
}
return build_message_string ("%s%s:%s ", text_cs, text, text_ce);
}
/* Return a malloc'd string describing a location. The caller is
responsible for freeing the memory. */
static char *
gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
expanded_location s)
{
pretty_printer *pp = context->printer;
const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
const char *locus_ce = colorize_stop (pp_show_color (pp));
return (s.file == NULL
? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
: !strcmp (s.file, N_("<built-in>"))
? build_message_string ("%s%s:%s", locus_cs, s.file, locus_ce)
: context->show_column
? build_message_string ("%s%s:%d:%d:%s", locus_cs, s.file, s.line,
s.column, locus_ce)
: build_message_string ("%s%s:%d:%s", locus_cs, s.file, s.line, locus_ce));
}
/* Return a malloc'd string describing two locations. The caller is
responsible for freeing the memory. */
static char *
gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
expanded_location s, expanded_location s2)
{
pretty_printer *pp = context->printer;
const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
const char *locus_ce = colorize_stop (pp_show_color (pp));
return (s.file == NULL
? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
: !strcmp (s.file, N_("<built-in>"))
? build_message_string ("%s%s:%s", locus_cs, s.file, locus_ce)
: context->show_column
? build_message_string ("%s%s:%d:%d-%d:%s", locus_cs, s.file, s.line,
MIN (s.column, s2.column),
MAX (s.column, s2.column), locus_ce)
: build_message_string ("%s%s:%d:%s", locus_cs, s.file, s.line,
locus_ce));
}
/* This function prints the locus (file:line:column), the diagnostic kind
(Error, Warning) and (optionally) the relevant lines of code with
annotation lines with '1' and/or '2' below them.
With -fdiagnostic-show-caret (the default) it prints:
[locus of primary range]:
some code
1
Error: Some error at (1)
With -fno-diagnostic-show-caret or if the primary range is not
valid, it prints:
[locus of primary range]: Error: Some error at (1) and (2)
*/
static void
gfc_diagnostic_starter (diagnostic_context *context,
diagnostic_info *diagnostic)
{
char * kind_prefix = gfc_diagnostic_build_kind_prefix (context, diagnostic);
expanded_location s1 = diagnostic_expand_location (diagnostic);
expanded_location s2;
bool one_locus = diagnostic->richloc->get_num_locations () < 2;
bool same_locus = false;
if (!one_locus)
{
s2 = diagnostic_expand_location (diagnostic, 1);
same_locus = diagnostic_same_line (context, s1, s2);
}
char * locus_prefix = (one_locus || !same_locus)
? gfc_diagnostic_build_locus_prefix (context, s1)
: gfc_diagnostic_build_locus_prefix (context, s1, s2);
if (!context->show_caret
|| diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
|| diagnostic_location (diagnostic, 0) == context->last_location)
{
pp_set_prefix (context->printer,
concat (locus_prefix, " ", kind_prefix, NULL));
free (locus_prefix);
if (one_locus || same_locus)
{
free (kind_prefix);
return;
}
/* In this case, we print the previous locus and prefix as:
[locus]:[prefix]: (1)
and we flush with a new line before setting the new prefix. */
pp_string (context->printer, "(1)");
pp_newline (context->printer);
locus_prefix = gfc_diagnostic_build_locus_prefix (context, s2);
pp_set_prefix (context->printer,
concat (locus_prefix, " ", kind_prefix, NULL));
free (kind_prefix);
free (locus_prefix);
}
else
{
pp_verbatim (context->printer, locus_prefix);
free (locus_prefix);
/* Fortran uses an empty line between locus and caret line. */
pp_newline (context->printer);
diagnostic_show_locus (context, diagnostic);
pp_newline (context->printer);
/* If the caret line was shown, the prefix does not contain the
locus. */
pp_set_prefix (context->printer, kind_prefix);
}
}
static void
gfc_diagnostic_finalizer (diagnostic_context *context,
diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
{
pp_destroy_prefix (context->printer);
pp_newline_and_flush (context->printer);
}
/* Immediate warning (i.e. do not buffer the warning) with an explicit
location. */
bool
gfc_warning_now_at (location_t loc, int opt, const char *gmsgid, ...)
{
va_list argp;
diagnostic_info diagnostic;
rich_location rich_loc (line_table, loc);
bool ret;
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_WARNING);
diagnostic.option_index = opt;
ret = report_diagnostic (&diagnostic);
va_end (argp);
return ret;
}
/* Immediate warning (i.e. do not buffer the warning). */
bool
gfc_warning_now (int opt, const char *gmsgid, ...)
{
va_list argp;
diagnostic_info diagnostic;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
bool ret;
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
DK_WARNING);
diagnostic.option_index = opt;
ret = report_diagnostic (&diagnostic);
va_end (argp);
return ret;
}
/* Immediate error (i.e. do not buffer). */
void
gfc_error_now (const char *gmsgid, ...)
{
va_list argp;
diagnostic_info diagnostic;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
error_buffer.flag = true;
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_ERROR);
report_diagnostic (&diagnostic);
va_end (argp);
}
/* Fatal error, never returns. */
void
gfc_fatal_error (const char *gmsgid, ...)
{
va_list argp;
diagnostic_info diagnostic;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_FATAL);
report_diagnostic (&diagnostic);
va_end (argp);
gcc_unreachable ();
}
/* Clear the warning flag. */
void
gfc_clear_warning (void)
{
gfc_clear_pp_buffer (pp_warning_buffer);
warningcount_buffered = 0;
werrorcount_buffered = 0;
}
/* Check to see if any warnings have been saved.
If so, print the warning. */
void
gfc_warning_check (void)
{
if (! gfc_output_buffer_empty_p (pp_warning_buffer))
{
pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer;
pp->buffer = pp_warning_buffer;
pp_really_flush (pp);
warningcount += warningcount_buffered;
werrorcount += werrorcount_buffered;
gcc_assert (warningcount_buffered + werrorcount_buffered == 1);
pp->buffer = tmp_buffer;
diagnostic_action_after_output (global_dc,
warningcount_buffered
? DK_WARNING : DK_ERROR);
}
}
/* Issue an error. */
static void
gfc_error (const char *gmsgid, va_list ap)
{
va_list argp;
va_copy (argp, ap);
if (warnings_not_errors)
{
gfc_warning (/*opt=*/0, gmsgid, argp);
va_end (argp);
return;
}
if (suppress_errors)
{
va_end (argp);
return;
}
diagnostic_info diagnostic;
rich_location richloc (line_table, UNKNOWN_LOCATION);
bool fatal_errors = global_dc->fatal_errors;
pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer;
gfc_clear_pp_buffer (pp_error_buffer);
if (buffered_p)
{
pp->buffer = pp_error_buffer;
global_dc->fatal_errors = false;
/* To prevent -fmax-errors= triggering, we decrease it before
report_diagnostic increases it. */
--errorcount;
}
diagnostic_set_info (&diagnostic, gmsgid, &argp, &richloc, DK_ERROR);
report_diagnostic (&diagnostic);
if (buffered_p)
{
pp->buffer = tmp_buffer;
global_dc->fatal_errors = fatal_errors;
}
va_end (argp);
}
void
gfc_error (const char *gmsgid, ...)
{
va_list argp;
va_start (argp, gmsgid);
gfc_error (gmsgid, argp);
va_end (argp);
}
/* This shouldn't happen... but sometimes does. */
void
gfc_internal_error (const char *gmsgid, ...)
{
va_list argp;
diagnostic_info diagnostic;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_ICE);
report_diagnostic (&diagnostic);
va_end (argp);
gcc_unreachable ();
}
/* Clear the error flag when we start to compile a source line. */
void
gfc_clear_error (void)
{
error_buffer.flag = 0;
warnings_not_errors = false;
gfc_clear_pp_buffer (pp_error_buffer);
}
/* Tests the state of error_flag. */
bool
gfc_error_flag_test (void)
{
return error_buffer.flag
|| !gfc_output_buffer_empty_p (pp_error_buffer);
}
/* Check to see if any errors have been saved.
If so, print the error. Returns the state of error_flag. */
bool
gfc_error_check (void)
{
if (error_buffer.flag
|| ! gfc_output_buffer_empty_p (pp_error_buffer))
{
error_buffer.flag = false;
pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer;
pp->buffer = pp_error_buffer;
pp_really_flush (pp);
++errorcount;
gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer));
pp->buffer = tmp_buffer;
diagnostic_action_after_output (global_dc, DK_ERROR);
return true;
}
return false;
}
/* Move the text buffered from FROM to TO, then clear
FROM. Independently if there was text in FROM, TO is also
cleared. */
static void
gfc_move_error_buffer_from_to (gfc_error_buffer * buffer_from,
gfc_error_buffer * buffer_to)
{
output_buffer * from = &(buffer_from->buffer);
output_buffer * to = &(buffer_to->buffer);
buffer_to->flag = buffer_from->flag;
buffer_from->flag = false;
gfc_clear_pp_buffer (to);
/* We make sure this is always buffered. */
to->flush_p = false;
if (! gfc_output_buffer_empty_p (from))
{
const char *str = output_buffer_formatted_text (from);
output_buffer_append_r (to, str, strlen (str));
gfc_clear_pp_buffer (from);
}
}
/* Save the existing error state. */
void
gfc_push_error (gfc_error_buffer *err)
{
gfc_move_error_buffer_from_to (&error_buffer, err);
}
/* Restore a previous pushed error state. */
void
gfc_pop_error (gfc_error_buffer *err)
{
gfc_move_error_buffer_from_to (err, &error_buffer);
}
/* Free a pushed error state, but keep the current error state. */
void
gfc_free_error (gfc_error_buffer *err)
{
gfc_clear_pp_buffer (&(err->buffer));
}
/* Report the number of warnings and errors that occurred to the caller. */
void
gfc_get_errors (int *w, int *e)
{
if (w != NULL)
*w = warningcount + werrorcount;
if (e != NULL)
*e = errorcount + sorrycount + werrorcount;
}
/* Switch errors into warnings. */
void
gfc_errors_to_warnings (bool f)
{
warnings_not_errors = f;
}
void
gfc_diagnostics_init (void)
{
diagnostic_starter (global_dc) = gfc_diagnostic_starter;
diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
diagnostic_format_decoder (global_dc) = gfc_format_decoder;
global_dc->caret_chars[0] = '1';
global_dc->caret_chars[1] = '2';
pp_warning_buffer = new (XNEW (output_buffer)) output_buffer ();
pp_warning_buffer->flush_p = false;
/* pp_error_buffer is statically allocated. This simplifies memory
management when using gfc_push/pop_error. */
pp_error_buffer = &(error_buffer.buffer);
pp_error_buffer->flush_p = false;
}
void
gfc_diagnostics_finish (void)
{
tree_diagnostics_defaults (global_dc);
/* We still want to use the gfc starter and finalizer, not the tree
defaults. */
diagnostic_starter (global_dc) = gfc_diagnostic_starter;
diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
global_dc->caret_chars[0] = '^';
global_dc->caret_chars[1] = '^';
}
|
rofirrim/gcc-tiny
|
gcc/fortran/error.c
|
C
|
gpl-2.0
| 34,191 |
#include <cogl/cogl.h>
#include <string.h>
#include <stdlib.h>
#include "test-declarations.h"
#include "test-utils.h"
typedef struct _TestState
{
int fb_width;
int fb_height;
} TestState;
#define PRIM_COLOR 0xff00ffff
#define TEX_COLOR 0x0000ffff
#define N_ATTRIBS 8
typedef CoglPrimitive * (* TestPrimFunc) (CoglContext *ctx, uint32_t *expected_color);
static CoglPrimitive *
test_prim_p2 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP2 verts[] =
{ { 0, 0 }, { 0, 10 }, { 10, 0 } };
return cogl_primitive_new_p2 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
test_prim_p3 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP3 verts[] =
{ { 0, 0, 0 }, { 0, 10, 0 }, { 10, 0, 0 } };
return cogl_primitive_new_p3 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
test_prim_p2c4 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP2C4 verts[] =
{ { 0, 0, 255, 255, 0, 255 },
{ 0, 10, 255, 255, 0, 255 },
{ 10, 0, 255, 255, 0, 255 } };
*expected_color = 0xffff00ff;
return cogl_primitive_new_p2c4 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
test_prim_p3c4 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP3C4 verts[] =
{ { 0, 0, 0, 255, 255, 0, 255 },
{ 0, 10, 0, 255, 255, 0, 255 },
{ 10, 0, 0, 255, 255, 0, 255 } };
*expected_color = 0xffff00ff;
return cogl_primitive_new_p3c4 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
test_prim_p2t2 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP2T2 verts[] =
{ { 0, 0, 1, 0 },
{ 0, 10, 1, 0 },
{ 10, 0, 1, 0 } };
*expected_color = TEX_COLOR;
return cogl_primitive_new_p2t2 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
test_prim_p3t2 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP3T2 verts[] =
{ { 0, 0, 0, 1, 0 },
{ 0, 10, 0, 1, 0 },
{ 10, 0, 0, 1, 0 } };
*expected_color = TEX_COLOR;
return cogl_primitive_new_p3t2 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
test_prim_p2t2c4 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP2T2C4 verts[] =
{ { 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
{ 0, 10, 1, 0, 0xff, 0xff, 0xf0, 0xff },
{ 10, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff } };
/* The blue component of the texture color should be replaced with 0xf0 */
*expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000;
return cogl_primitive_new_p2t2c4 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
test_prim_p3t2c4 (CoglContext *ctx, uint32_t *expected_color)
{
static const CoglVertexP3T2C4 verts[] =
{ { 0, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
{ 0, 10, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
{ 10, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff } };
/* The blue component of the texture color should be replaced with 0xf0 */
*expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000;
return cogl_primitive_new_p3t2c4 (test_ctx,
COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static const TestPrimFunc
test_prim_funcs[] =
{
test_prim_p2,
test_prim_p3,
test_prim_p2c4,
test_prim_p3c4,
test_prim_p2t2,
test_prim_p3t2,
test_prim_p2t2c4,
test_prim_p3t2c4
};
static void
test_paint (TestState *state)
{
CoglPipeline *pipeline;
CoglTexture *tex;
uint8_t tex_data[6];
int i;
/* Create a two pixel texture. The first pixel is white and the
second pixel is tex_color. The assumption is that if no texture
coordinates are specified then it will default to 0,0 and get
white */
tex_data[0] = 255;
tex_data[1] = 255;
tex_data[2] = 255;
tex_data[3] = (TEX_COLOR >> 24) & 0xff;
tex_data[4] = (TEX_COLOR >> 16) & 0xff;
tex_data[5] = (TEX_COLOR >> 8) & 0xff;
tex = test_utils_texture_new_from_data (test_ctx,
2, 1, /* size */
TEST_UTILS_TEXTURE_NO_ATLAS,
COGL_PIXEL_FORMAT_RGB_888,
6, /* rowstride */
tex_data);
pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline,
(PRIM_COLOR >> 24) & 0xff,
(PRIM_COLOR >> 16) & 0xff,
(PRIM_COLOR >> 8) & 0xff,
(PRIM_COLOR >> 0) & 0xff);
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
cogl_object_unref (tex);
for (i = 0; i < G_N_ELEMENTS (test_prim_funcs); i++)
{
CoglPrimitive *prim;
uint32_t expected_color = PRIM_COLOR;
prim = test_prim_funcs[i] (test_ctx, &expected_color);
cogl_framebuffer_push_matrix (test_fb);
cogl_framebuffer_translate (test_fb, i * 10, 0, 0);
cogl_primitive_draw (prim, test_fb, pipeline);
cogl_framebuffer_pop_matrix (test_fb);
test_utils_check_pixel (test_fb, i * 10 + 2, 2, expected_color);
cogl_object_unref (prim);
}
cogl_object_unref (pipeline);
}
static gboolean
get_attributes_cb (CoglPrimitive *prim,
CoglAttribute *attrib,
void *user_data)
{
CoglAttribute ***p = user_data;
*((* p)++) = attrib;
return TRUE;
}
static int
compare_pointers (const void *a, const void *b)
{
CoglAttribute *pa = *(CoglAttribute **) a;
CoglAttribute *pb = *(CoglAttribute **) b;
if (pa < pb)
return -1;
else if (pa > pb)
return 1;
else
return 0;
}
static void
test_copy (TestState *state)
{
static const uint16_t indices_data[2] = { 1, 2 };
CoglAttributeBuffer *buffer =
cogl_attribute_buffer_new (test_ctx, 100, NULL);
CoglAttribute *attributes[N_ATTRIBS];
CoglAttribute *attributes_a[N_ATTRIBS], *attributes_b[N_ATTRIBS];
CoglAttribute **p;
CoglPrimitive *prim_a, *prim_b;
CoglIndices *indices;
int i;
for (i = 0; i < N_ATTRIBS; i++)
{
char *name = g_strdup_printf ("foo_%i", i);
attributes[i] = cogl_attribute_new (buffer,
name,
16, /* stride */
16, /* offset */
2, /* components */
COGL_ATTRIBUTE_TYPE_FLOAT);
g_free (name);
}
prim_a = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES,
8, /* n_vertices */
attributes,
N_ATTRIBS);
indices = cogl_indices_new (test_ctx,
COGL_INDICES_TYPE_UNSIGNED_SHORT,
indices_data,
2 /* n_indices */);
cogl_primitive_set_first_vertex (prim_a, 12);
cogl_primitive_set_indices (prim_a, indices, 2);
prim_b = cogl_primitive_copy (prim_a);
p = attributes_a;
cogl_primitive_foreach_attribute (prim_a,
get_attributes_cb,
&p);
g_assert_cmpint (p - attributes_a, ==, N_ATTRIBS);
p = attributes_b;
cogl_primitive_foreach_attribute (prim_b,
get_attributes_cb,
&p);
g_assert_cmpint (p - attributes_b, ==, N_ATTRIBS);
qsort (attributes_a, N_ATTRIBS, sizeof (CoglAttribute *), compare_pointers);
qsort (attributes_b, N_ATTRIBS, sizeof (CoglAttribute *), compare_pointers);
g_assert (memcmp (attributes_a, attributes_b, sizeof (attributes_a)) == 0);
g_assert_cmpint (cogl_primitive_get_first_vertex (prim_a),
==,
cogl_primitive_get_first_vertex (prim_b));
g_assert_cmpint (cogl_primitive_get_n_vertices (prim_a),
==,
cogl_primitive_get_n_vertices (prim_b));
g_assert_cmpint (cogl_primitive_get_mode (prim_a),
==,
cogl_primitive_get_mode (prim_b));
g_assert (cogl_primitive_get_indices (prim_a) ==
cogl_primitive_get_indices (prim_b));
cogl_object_unref (prim_a);
cogl_object_unref (prim_b);
cogl_object_unref (indices);
for (i = 0; i < N_ATTRIBS; i++)
cogl_object_unref (attributes[i]);
cogl_object_unref (buffer);
}
void
test_primitive (void)
{
TestState state;
state.fb_width = cogl_framebuffer_get_width (test_fb);
state.fb_height = cogl_framebuffer_get_height (test_fb);
cogl_framebuffer_orthographic (test_fb,
0, 0,
state.fb_width,
state.fb_height,
-1,
100);
test_paint (&state);
test_copy (&state);
if (cogl_test_verbose ())
g_print ("OK\n");
}
|
GNOME/mutter
|
cogl/tests/conform/test-primitive.c
|
C
|
gpl-2.0
| 10,034 |
/*
* Copyright (C) 2010 NXP Semiconductors
*/
#include <linux/nfc/pn544_lge.h>
//
#include "pn544_lge_hwadapter.h"
#ifdef CONFIG_LGE_NFC_MULTICORE_FASTBOOT
#include <linux/kthread.h>
#endif
/* */
#define MAX_BUFFER_SIZE 512
#define PN544_RESET_CMD 0
#define PN544_DOWNLOAD_CMD 1
#ifdef LGE_NFC_READ_IRQ_MODIFY
bool do_reading = false;//DY_TEST
static bool cancle_read = false;//DY_TEST
#endif
static int stReadIntFlag;
static struct i2c_client *pn544_client;
static void pn544_disable_irq(struct pn544_dev *pn544_dev)
{
unsigned long flags;
spin_lock_irqsave(&pn544_dev->irq_enabled_lock, flags);
if (pn544_dev->irq_enabled) {
disable_irq_nosync(pn544_get_irq_pin(pn544_dev));
//
#if !defined(CONFIG_LGE_NFC_HW_QCT_MSM8660)&&!defined(CONFIG_LGE_NFC_HW_QCT_MSM8255)
disable_irq_wake(pn544_get_irq_pin(pn544_dev));
#endif
pn544_dev->irq_enabled = false;
}
spin_unlock_irqrestore(&pn544_dev->irq_enabled_lock, flags);
}
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
dprintk(PN544_DRV_NAME ":pn544_dev_irq_handler : %d\n", irq);
pn544_disable_irq(pn544_dev);
#ifdef LGE_NFC_READ_IRQ_MODIFY
do_reading=1;//DY_TEST
#endif
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
return IRQ_HANDLED;
}
#ifdef CONFIG_LGE_NFC_PRESTANDBY
#ifdef CONFIG_LGE_NFC_PN544_C2
void pn544_factory_standby_set(void)
{
int ret;
struct pn544_dev *pn544_dev;
struct pn544_i2c_platform_data *platform_data;
uint8_t EEDATA_WRITE[9] = {0x08, 0x00, 0x06, 0x00, 0x9E, 0xAA, 0x00, 0x01, 0x01};
platform_data = pn544_client->dev.platform_data;
pn544_dev = i2c_get_clientdata(pn544_client);
// 1. Go To Dnld mode 2
gpio_set_value(platform_data->ven_gpio, 1);
gpio_set_value(platform_data->firm_gpio, 1);
msleep(10);
gpio_set_value(platform_data->ven_gpio, 0);
msleep(10);
gpio_set_value(platform_data->ven_gpio, 1);
msleep(10);
// 2. I2c write
dprintk("%s Go To I2c write\n", __func__);
ret = 0;
ret = i2c_master_send(pn544_client, EEDATA_WRITE, 9);
if (ret != 9) {
dprintk(PN544_DRV_NAME ":%s : i2c_master_send returned %d\n", __func__, ret);
}
msleep(10);
// 3. HW reset 1,0,1
dprintk("%s Go To PN544 reset\n", __func__);
//--> # reset 1
gpio_set_value(platform_data->firm_gpio, 0);
gpio_set_value(platform_data->ven_gpio, 1);
msleep(10);
//--> # reset 0
gpio_set_value(platform_data->firm_gpio, 0);
gpio_set_value(platform_data->ven_gpio, 0);
msleep(10);
//--> # reset 1
gpio_set_value(platform_data->firm_gpio, 0);
gpio_set_value(platform_data->ven_gpio, 1);
msleep(10);
// 4. power off
dprintk(PN544_DRV_NAME ":%s power off\n", __func__);
gpio_set_value(pn544_dev->firm_gpio, 0);
gpio_set_value(pn544_dev->ven_gpio, 0);
msleep(10);
}
#elif defined(CONFIG_LGE_NFC_PN544_C3)
static char pn544_standby_set_val1[6]={0x05, 0xF9, 0x04, 0x00, 0xC3, 0xE5};
static char pn544_standby_set_val2[6]={0x05, 0x80, 0x83, 0x03, 0x5A, 0x0A};
static char pn544_standby_set_val3[10]={0x09, 0x89, 0x83, 0x3F, 0x00, 0x9E, 0xAA, 0x01, 0xC2, 0x85};
#define NFC_I2C_WRITE_RETRY_NUM 3
static int __pn544_kwrite(void *dev, void* data, int size)
{
struct pn544_dev *pn544_dev;
int ret = 0;
unsigned int retry = 0;
if(dev != NULL)
pn544_dev = (struct pn544_dev*)dev;
ret = i2c_master_send(pn544_client, data, size);
while(retry != NFC_I2C_WRITE_RETRY_NUM)
{
msleep(10);
if(ret == size)
break;
ret = i2c_master_send(pn544_client, data, size);
retry++;
printk("%s i2c_master_send retry[%d]\n",__func__, retry);
}
if(ret != size){
pr_err("%s i2c_master_send failed[%d]\n", __func__, ret);
return -1;
}
return 0;
}
static int __pn544_kread(void *dev, unsigned int length)
{
struct pn544_dev *pn544_dev = NULL;
char tmp[MAX_BUFFER_SIZE];
int ret = 0;
int irq_gpio_val = 0;
if(dev != NULL)
pn544_dev = (struct pn544_dev*)dev;
mutex_lock(&pn544_dev->read_mutex);
irq_gpio_val = gpio_get_value(pn544_dev->irq_gpio);
dprintk(PN544_DRV_NAME ":IRQ GPIO = %d\n", irq_gpio_val);
if (irq_gpio_val == 0) {
pn544_dev->irq_enabled = true;
#ifdef READ_IRQ_MODIFY
do_reading=0;//DY_TEST
#endif
enable_irq_wake(pn544_get_irq_pin(pn544_dev));
enable_irq(pn544_get_irq_pin(pn544_dev));
#ifdef READ_IRQ_MODIFY
ret = wait_event_interruptible(pn544_dev->read_wq, do_reading);
#else
ret = wait_event_interruptible(pn544_dev->read_wq, gpio_get_value(pn544_dev->irq_gpio));
#endif
pn544_disable_irq(pn544_dev);
if(ret){
mutex_unlock(&pn544_dev->read_mutex);
goto fail;
}
}
memset(tmp, 0x00, MAX_BUFFER_SIZE);
ret = i2c_master_recv(pn544_dev->client, tmp, length);
while(tmp[0]==0x51&&tmp[1]==0xFF&&tmp[2]==0xFF){
ret = i2c_master_recv(pn544_dev->client, tmp, length);
printk("%s read retry!\n", __func__);
}
mutex_unlock(&pn544_dev->read_mutex);
printk("%s: read data : 0x%X 0x%X 0x%X 0x%X\n", __func__, tmp[0], tmp[1], tmp[2], tmp[3]);
if (ret < 0) {
dprintk("%s: i2c_master_recv returned %d\n", __func__, ret);
return ret;
}
if (ret > length) {
pr_err("%s: received too many bytes from i2c (%d)\n", __func__, ret);
return -EIO;
}
fail:
return ret;
}
void pn544_factory_standby_set(void)
{
int ret = 0;
struct pn544_dev *pn544_dev;
struct pn544_i2c_platform_data *platform_data;
platform_data = pn544_client->dev.platform_data;
pn544_dev = i2c_get_clientdata(pn544_client);
// 1. Go To Dnld mode 2
dprintk("%s Go To Dnld mode 2\n", __func__);
gpio_set_value(platform_data->ven_gpio, 0);
gpio_set_value(platform_data->firm_gpio, 0);
msleep(10);
gpio_set_value(platform_data->ven_gpio, 1);
msleep(10);
// 2. I2c write
dprintk("%s Go To I2c write\n", __func__);
ret = __pn544_kwrite(pn544_dev, pn544_standby_set_val1, 6);
if (ret == 0) {
printk("%s: standby write val1 success\n", __func__);
ret = __pn544_kread(pn544_dev, 4);
} else {
printk("%s: standby write val1 fail\n", __func__);
return;
}
ret = __pn544_kwrite(pn544_dev, pn544_standby_set_val2, 6);
if (ret == 0) {
printk("%s: standby write val2 success\n", __func__);
ret = __pn544_kread(pn544_dev, 6);
} else {
printk("%s: standby write val2 fail\n", __func__);
return;
}
ret = __pn544_kwrite(pn544_dev, pn544_standby_set_val3, 10);
if (ret == 0) {
printk("%s: standby write val3 success\n", __func__);
ret = __pn544_kread(pn544_dev, 7);
} else {
printk("%s: standby write val3 fail\n", __func__);
return;
}
// 4. power off
dprintk(PN544_DRV_NAME ":%s power off\n", __func__);
gpio_set_value(pn544_dev->firm_gpio, 0);
gpio_set_value(pn544_dev->ven_gpio, 0);
msleep(10);
return;
}
#endif /* */
#endif /* */
/*
*/
#if defined(CONFIG_LGE_NFC_MULTICORE_FASTBOOT)&&defined(CONFIG_LGE_NFC_PRESTANDBY)
static int pn544_factory_standby_set_thread(void *arg)
{
pn544_factory_standby_set();
dprintk("%s end\n", __func__);
return 0;
}
#endif /* */
/* */
static ssize_t pn544_dev_read(struct file *filp, char __user *buf,
size_t count, loff_t *offset)
{
struct pn544_dev *pn544_dev = filp->private_data;
static char tmp[MAX_BUFFER_SIZE];
int ret;
int irq_gpio_val = 0;
if (count > MAX_BUFFER_SIZE)
count = MAX_BUFFER_SIZE;
pr_debug("%s : reading %zu bytes.\n", __func__, count);
mutex_lock(&pn544_dev->read_mutex);
if (!stReadIntFlag) {
irq_gpio_val = gpio_get_value(pn544_dev->irq_gpio);
dprintk(PN544_DRV_NAME ":IRQ GPIO = %d\n", irq_gpio_val);
if (irq_gpio_val == 0) {
if (filp->f_flags & O_NONBLOCK) {
pr_err(PN544_DRV_NAME ":f_falg has O_NONBLOCK. EAGAIN!\n");
ret = -EAGAIN;
goto fail;
}
pn544_dev->irq_enabled = true;
#ifdef LGE_NFC_READ_IRQ_MODIFY
do_reading=0;//DY_TEST
#endif
//
#if !defined(LGE_NFC_HW_QCT_MSM8660)
enable_irq_wake(pn544_get_irq_pin(pn544_dev));
#endif
enable_irq(pn544_get_irq_pin(pn544_dev));
#ifdef LGE_NFC_READ_IRQ_MODIFY
ret = wait_event_interruptible(pn544_dev->read_wq, do_reading);
#else
ret = wait_event_interruptible(pn544_dev->read_wq,
gpio_get_value(pn544_dev->irq_gpio));
#endif
pn544_disable_irq(pn544_dev);
//dprintk(PN544_DRV_NAME ":wait_event_interruptible : %d\n", ret);
#ifdef LGE_NFC_READ_IRQ_MODIFY
//DY_TEST
if(cancle_read == true)
{
cancle_read = false;
ret = -1;
goto fail;
}
#endif
if (ret)
goto fail;
}
}
/* Read data */
memset(tmp, 0x00, MAX_BUFFER_SIZE);
ret = i2c_master_recv(pn544_dev->client, tmp, count);
mutex_unlock(&pn544_dev->read_mutex);
if (ret < 0) {
pr_err("%s: i2c_master_recv returned %d\n", __func__, ret);
return ret;
}
if (ret > count) {
pr_err("%s: received too many bytes from i2c (%d)\n",
__func__, ret);
return -EIO;
}
if (copy_to_user(buf, tmp, ret)) {
pr_warning("%s : failed to copy to user space\n", __func__);
return -EFAULT;
}
return ret;
fail:
mutex_unlock(&pn544_dev->read_mutex);
return ret;
}
static ssize_t pn544_dev_write(struct file *filp, const char __user *buf,
size_t count, loff_t *offset)
{
struct pn544_dev *pn544_dev;
static char tmp[MAX_BUFFER_SIZE];
int ret;
pn544_dev = filp->private_data;
if (count > MAX_BUFFER_SIZE)
count = MAX_BUFFER_SIZE;
memset(tmp, 0x00, MAX_BUFFER_SIZE);
if (copy_from_user(tmp, buf, count)) {
pr_err(PN544_DRV_NAME ":%s : failed to copy from user space\n", __func__);
return -EFAULT;
}
pr_debug("%s : writing %zu bytes.\n", __func__, count);
/* Write data */
dprintk(PN544_DRV_NAME ":write: pn544_write len=:%d\n", count);
ret = i2c_master_send(pn544_dev->client, tmp, count);
if (ret != count) {
pr_err("%s : i2c_master_send returned %d\n", __func__, ret);
ret = -EIO;
}
return ret;
}
static int pn544_dev_open(struct inode *inode, struct file *filp)
{
filp->private_data = i2c_get_clientdata(pn544_client);
pr_debug("%s : %d,%d\n", __func__, imajor(inode), iminor(inode));
return 0;
}
static long pn544_dev_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct pn544_dev *pn544_dev = filp->private_data;
switch (cmd) {
case PN544_SET_PWR:
if (arg == 2) {
/*
power on with firmware download (requires hw reset)
*/
dprintk(PN544_DRV_NAME ":%s power on with firmware\n", __func__);
gpio_set_value(pn544_dev->ven_gpio, 1);
gpio_set_value(pn544_dev->firm_gpio, 1);
msleep(10);
gpio_set_value(pn544_dev->ven_gpio, 0);
msleep(10);
gpio_set_value(pn544_dev->ven_gpio, 1);
msleep(10);
} else if (arg == 1) {
/* power on */
dprintk(PN544_DRV_NAME ":%s power on\n", __func__);
gpio_set_value(pn544_dev->firm_gpio, 0);
gpio_set_value(pn544_dev->ven_gpio, 1);
msleep(10);
#ifdef CONFIG_LGE_NFC_SET_IRQ_WAKEUP
irq_set_irq_wake(pn544_dev->client->irq,1);
dprintk(PN544_DRV_NAME ":%s enable IRQ\n", __func__);
#endif
} else if (arg == 0) {
/* power off */
dprintk(PN544_DRV_NAME ":%s power off\n", __func__);
gpio_set_value(pn544_dev->firm_gpio, 0);
gpio_set_value(pn544_dev->ven_gpio, 0);
msleep(10);
#ifdef CONFIG_LGE_NFC_SET_IRQ_WAKEUP
irq_set_irq_wake(pn544_dev->client->irq,0);
dprintk(PN544_DRV_NAME ":%s disable IRQ\n", __func__);
#endif
#ifdef LGE_NFC_READ_IRQ_MODIFY
} else if (arg == 3) {//DY_TEST
dprintk("%s Read Cancle\n", __func__);
cancle_read = true;
do_reading = 1;
wake_up(&pn544_dev->read_wq);
#endif
} else {
pr_err("%s bad arg %ld\n", __func__, arg);
return -EINVAL;
}
break;
case PN544_INTERRUPT_CMD:
{
/*
pn544_disable_irq = level;
*/
dprintk(PN544_DRV_NAME ":ioctl: pn544_interrupt enable level:%ld\n", arg);
break;
}
case PN544_READ_POLLING_CMD:
{
stReadIntFlag = arg;
dprintk(PN544_DRV_NAME ":ioctl: pn544_polling flag set:%ld\n", arg);
break;
}
case PN544_HW_REVISION:
{
return pn544_get_hw_revision();
}
default:
pr_err("%s bad ioctl %d\n", __func__, cmd);
return -EINVAL;
}
return 0;
}
static const struct file_operations pn544_dev_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = pn544_dev_read,
.write = pn544_dev_write,
.open = pn544_dev_open,
.unlocked_ioctl = pn544_dev_unlocked_ioctl,
};
static int pn544_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int ret;
struct pn544_i2c_platform_data *platform_data;
struct pn544_dev *pn544_dev = NULL;
dprintk(PN544_DRV_NAME ": pn544_probe() start\n");
pn544_client = client;
platform_data = client->dev.platform_data;
if (platform_data == NULL) {
pr_err("%s : nfc probe fail\n", __func__);
return -ENODEV;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
pr_err("%s : need I2C_FUNC_I2C\n", __func__);
return -ENODEV;
}
ret = gpio_request(platform_data->irq_gpio, "nfc_int");
if (ret) {
dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_int request failed!\n");
return -ENODEV;
}
ret = gpio_request(platform_data->ven_gpio, "nfc_ven");
if (ret) {
dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_ven request failed!\n");
goto err_ven;
}
ret = gpio_request(platform_data->firm_gpio, "nfc_firm");
if (ret) {
dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_firm request failed!\n");
goto err_firm;
}
pn544_dev = kzalloc(sizeof(*pn544_dev), GFP_KERNEL);
if (pn544_dev == NULL) {
dev_err(&client->dev,
"failed to allocate memory for module data\n");
ret = -ENOMEM;
goto err_exit;
}
pn544_dev->irq_gpio = platform_data->irq_gpio;
pn544_dev->ven_gpio = platform_data->ven_gpio;
pn544_dev->firm_gpio = platform_data->firm_gpio;
pn544_dev->client = client;
dprintk(PN544_DRV_NAME ":IRQ : %d\nVEN : %d\nFIRM : %d\n",
pn544_dev->irq_gpio, pn544_dev->ven_gpio, pn544_dev->firm_gpio);
pn544_gpio_enable(pn544_dev);
ret = gpio_direction_output(platform_data->ven_gpio,1);
ret = gpio_direction_output(platform_data->firm_gpio,0);
ret = gpio_direction_input(platform_data->irq_gpio);
/* init mutex and queues */
init_waitqueue_head(&pn544_dev->read_wq);
mutex_init(&pn544_dev->read_mutex);
spin_lock_init(&pn544_dev->irq_enabled_lock);
pn544_dev->pn544_device.minor = MISC_DYNAMIC_MINOR;
pn544_dev->pn544_device.name = PN544_DRV_NAME;
pn544_dev->pn544_device.fops = &pn544_dev_fops;
ret = misc_register(&pn544_dev->pn544_device);
if (ret) {
pr_err("%s : misc_register failed\n", __FILE__);
goto err_misc_register;
}
/* request irq. the irq is set whenever the chip has data available
* for reading. it is cleared when all data has been read.
*/
pr_info("%s : requesting IRQ %d\n", __func__, client->irq);
pn544_dev->irq_enabled = true;
ret = request_irq(pn544_gpio_to_irq(pn544_dev), pn544_dev_irq_handler,
IRQF_TRIGGER_HIGH, client->name, pn544_dev);
if (ret) {
dev_err(&client->dev, "request_irq failed\n");
goto err_request_irq_failed;
}
#if !defined(LGE_NFC_HW_QCT_MSM8660)&&!defined(CONFIG_LGE_NFC_HW_QCT_MSM8255)
enable_irq_wake(pn544_get_irq_pin(pn544_dev));
#endif
pn544_disable_irq(pn544_dev);
i2c_set_clientdata(client, pn544_dev);
dprintk(PN544_DRV_NAME ": pn544_probe() end\n");
/*
*/
#ifdef CONFIG_LGE_NFC_MULTICORE_FASTBOOT
{
struct task_struct *th;
th = kthread_create(pn544_factory_standby_set_thread, NULL, "pn544_factory_standby");
if (IS_ERR(th)) {
ret = PTR_ERR(th);
goto err_request_irq_failed;
}
wake_up_process(th);
}
#else
pn544_factory_standby_set();
#endif
/* */
return 0;
err_request_irq_failed:
misc_deregister(&pn544_dev->pn544_device);
err_misc_register:
mutex_destroy(&pn544_dev->read_mutex);
kfree(pn544_dev);
err_firm:
gpio_free(pn544_dev->firm_gpio);
err_ven:
gpio_free(pn544_dev->ven_gpio);
//
err_exit:
pr_err(PN544_DRV_NAME ": pn544_dev is null\n");
pr_err(PN544_DRV_NAME ": pn544_probe() end with error!\n");
return ret;
}
static int pn544_remove(struct i2c_client *client)
{
struct pn544_dev *pn544_dev;
pn544_dev = i2c_get_clientdata(client);
free_irq(pn544_gpio_to_irq(pn544_dev), pn544_dev);
misc_deregister(&pn544_dev->pn544_device);
mutex_destroy(&pn544_dev->read_mutex);
gpio_free(pn544_dev->irq_gpio);
gpio_free(pn544_dev->ven_gpio);
gpio_free(pn544_dev->firm_gpio);
kfree(pn544_dev);
return 0;
}
static void pn544_shutdown(struct i2c_client *client)
{
struct pn544_dev *pn544_dev;
// Get PN544 Device Structure data
pn544_dev = i2c_get_clientdata(client);
pn544_shutdown_cb(pn544_dev);
return;
}
static const struct i2c_device_id pn544_id[] = {
{ PN544_DRV_NAME, 0 },
{ }
};
static struct i2c_driver pn544_driver = {
.id_table = pn544_id,
.probe = pn544_probe,
.remove = pn544_remove,
.shutdown = pn544_shutdown,
.driver = {
.owner = THIS_MODULE,
.name = PN544_DRV_NAME,
},
};
/*
* module load/unload record keeping
*/
static int __init pn544_dev_init(void)
{
pr_info("Loading pn544 driver\n");
return i2c_add_driver(&pn544_driver);
}
module_init(pn544_dev_init);
static void __exit pn544_dev_exit(void)
{
pr_info("Unloading pn544 driver\n");
i2c_del_driver(&pn544_driver);
}
module_exit(pn544_dev_exit);
MODULE_AUTHOR("Sylvain Fonteneau");
MODULE_DESCRIPTION("NFC PN544 driver");
MODULE_LICENSE("GPL");
|
playfulgod/kernel_lge_fx3
|
drivers/nfc/pn544_lge.c
|
C
|
gpl-2.0
| 18,532 |
#include "glheader.h"
#include "macros.h"
#include "mtypes.h"
#include "colormac.h"
#include "i810screen.h"
#include "i810_dri.h"
#include "i810span.h"
#include "i810ioctl.h"
#include "swrast/swrast.h"
#define DBG 0
#define LOCAL_VARS \
i810ContextPtr imesa = I810_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = imesa->driDrawable; \
driRenderbuffer *drb = (driRenderbuffer *) rb; \
GLuint pitch = drb->pitch; \
GLuint height = dPriv->h; \
GLushort p; \
char *buf = (char *)(drb->flippedData + \
dPriv->x * 2 + \
dPriv->y * pitch); \
(void) buf; (void) p
#define LOCAL_DEPTH_VARS \
i810ContextPtr imesa = I810_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = imesa->driDrawable; \
driRenderbuffer *drb = (driRenderbuffer *) rb; \
GLuint pitch = drb->pitch; \
GLuint height = dPriv->h; \
char *buf = (char *)(drb->Base.Data + \
dPriv->x * 2 + \
dPriv->y * pitch)
#define INIT_MONO_PIXEL(p, color) \
p = PACK_COLOR_565( color[0], color[1], color[2] )
#define Y_FLIP(_y) (height - _y - 1)
#define HW_LOCK()
#define HW_UNLOCK()
/* 16 bit, 565 rgb color spanline and pixel functions
*/
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = ( (((int)r & 0xf8) << 8) | \
(((int)g & 0xfc) << 3) | \
(((int)b & 0xf8) >> 3))
#define WRITE_PIXEL( _x, _y, p ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = p
#define READ_RGBA( rgba, _x, _y ) \
do { \
GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
rgba[3] = 255; \
} while(0)
#define TAG(x) i810##x##_565
#include "spantmp.h"
/* 16 bit depthbuffer functions.
*/
#define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
#define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
#define TAG(x) i810##x##_z16
#include "depthtmp.h"
/* Move locking out to get reasonable span performance.
*/
void i810SpanRenderStart( GLcontext *ctx )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
I810_FIREVERTICES(imesa);
LOCK_HARDWARE(imesa);
i810RegetLockQuiescent( imesa );
}
void i810SpanRenderFinish( GLcontext *ctx )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
_swrast_flush( ctx );
UNLOCK_HARDWARE( imesa );
}
void i810InitSpanFuncs( GLcontext *ctx )
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
swdd->SpanRenderStart = i810SpanRenderStart;
swdd->SpanRenderFinish = i810SpanRenderFinish;
}
/**
* Plug in the Get/Put routines for the given driRenderbuffer.
*/
void
i810SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
{
if (drb->Base.InternalFormat == GL_RGBA) {
/* always 565 RGB */
i810InitPointers_565(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
i810InitDepthPointers_z16(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
/* should never get here */
drb->Base.GetRow = NULL;
drb->Base.GetValues = NULL;
drb->Base.PutRow = NULL;
drb->Base.PutMonoRow = NULL;
drb->Base.PutValues = NULL;
drb->Base.PutMonoValues = NULL;
}
else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
drb->Base.GetRow = NULL;
drb->Base.GetValues = NULL;
drb->Base.PutRow = NULL;
drb->Base.PutMonoRow = NULL;
drb->Base.PutValues = NULL;
drb->Base.PutMonoValues = NULL;
}
}
|
ZHAW-INES/rioxo-uClinux-dist
|
lib/mesa/src/mesa/drivers/dri/i810/i810span.c
|
C
|
gpl-2.0
| 3,740 |
/*
+ Generated with SMK SKINR v1.0
+ Customized by Smartik
+ Date and time: 09/10/2012 09:33:03 pm - Australia/Melbourne
+ SMK SKINR URL: http://www.smartik-themes.com/themeforest/html/perspective/template-builder.php
+ Color Scheme: #004d4d | #008585 | #00a3a3 | #00c7c7
+ General info:
header: ../../images/headers/header63.jpg
wrap: none
loader: ../../images/loaders/1.gif
caption: ../../images/caption/24.png
footer: ../../images/pattern/62.png
blog icons set: 0
*/
/*Links*/
a {
color: #004d4d;
transition: all .3s;
-moz-transition: all .3s;
-webkit-transition: all .3s;
-o-transition: all .3s;
}
a:hover,
h1 a:hover,
h2 a:hover,
h3 a:hover,
h4 a:hover,
h5 a:hover,
h6 a:hover {
color: #008585
}
/*Top Bar(with menu)*/
.top_head_separator{
background: #FFFFFF;
border-bottom: #EEEEEE solid 10px;
}
/*Menu*/
.nav_simple ul li a {
border-bottom: 1px solid transparent;
padding-top: 7px;
padding-bottom: 7px;
}
.nav_simple ul li a:hover,
.nav_simple ul li a.hov,
.nav_simple ul li a.active {
border-bottom: 1px solid #008585;
background: #222222;
color: #FFFFFF;
}
.nav_simple li.nav_badge em,
.nav_simple li.nav_badge a em{
background: #00c7c7;
color: #fff;
}
/*Header*/
.header,
.page_top_details{
background: url(../../images/headers/header63.jpg) center top #ffffff;
border-bottom: 10px solid #EEEEEE;
}
/*Wrap*/
.wrap{
background: #ffffff;
}
/*Image/Video Wrap*/
.image_wrap,
.image_wrap_simple,
.blog_article .blog_slider.flexslider,
.post_article_single .post_slider.flexslider,
.blog_article .container_video,
.post_article_single .container_video{
background: #fafafa;
}
.image_wrap:hover,
.image_wrap_simple:hover,
.blog_article .blog_slider.flexslider:hover,
.post_article_single .post_slider.flexslider:hover,
.blog_article .container_video:hover,
.post_article_single .container_video:hover{
background: #eaeaea;
}
.img_wrap_in{
margin: 5px;
}
.image_wrap,
.image_wrap_simple,
.blog_article .blog_slider.flexslider,
.post_article_single .post_slider.flexslider,
.blog_article .container_video,
.post_article_single .container_video,
.image_wrap img,
.image_wrap_simple img,
.blog_article .blog_slider.flexslider img,
.post_article_single .post_slider.flexslider img,
.blog_article .container_video iframe,
.post_article_single .container_video iframe,
.img_wrap_in{
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
}
/*Forms*/
input[type=text],
input[type=password],
input[type=url],
input[type=email],
input.text,
input.title,
textarea,
select{
border-color: #BBBBBB;
background: #FFFFFF;
color: #000000;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
input[type=text]:focus,
input[type=password]:focus,
input[type=url]:focus,
input[type=email]:focus,
input.text:focus,
input.title:focus,
textarea:focus,
select:focus{
border-color: #008585;
background: #FFFFFF;
color: #000000;
}
/*Image Preloader*/
.preloader { background:url(../../images/loaders/1.gif) center center no-repeat #ffffff; }
/*Site Footer*/
#site_footer{
background-image: url(../../images/pattern/62.png);
background-color: #32303D;
background-repeat: repeat;
background-position: center top;
}
#site_footer
#site_footer .widgetized_footer,
#site_footer .widgetized_footer .widget-title,
#site_footer .widgetized_footer .widget ul li{
color: #FFFFFF;
}
#site_footer .widgetized_footer a,
#site_footer .widgetized_footer .widget ul li a{
color: #FFFFFF;
}
#site_footer a:hover,
#site_footer .widgetized_footer a:hover,
#site_footer .widgetized_footer .widget ul li a:hover{
color: #00c7c7;
}
#site_footer_second{
background: #32303D;
border-top: 1px solid #49475C;
}
#site_footer_second,
#site_footer_second .site_footer_inner,
.site_copyright{
color: #FFFFFF;
}
#site_footer_second a,
#site_footer_second .site_footer_inner a{
color: #FFFFFF;
}
#site_footer_second a:hover,
#site_footer_second .site_footer_inner a:hover{
color: #00c7c7;
}
/* Blog icons */
.blog_article.blog_article_s3 .blog_s3_meta ul.metasingle li.blog_user {
background-image: url(../../images/icons/blog/blog-user0.png);
}
.blog_article.blog_article_s3 .blog_s3_meta ul.metasingle li.blog_date {
background-image: url(../../images/icons/blog/blog-calendar0.png);
}
.blog_article.blog_article_s3 .blog_s3_meta ul.metasingle li.blog_category {
background-image: url(../../images/icons/blog/blog-category0.png);
}
.blog_article.blog_article_s3 .blog_s3_meta ul.metasingle li.blog_comments {
background-image: url(../../images/icons/blog/blog-comments0.png);
}
.blog_article.blog_article_s3 .blog_s3_meta ul.metasingle li.blog_tag {
background-image: url(../../images/icons/blog/blog-tag0.png);
}
/* Image hover icon */
.image_wrap .img_caption_zoom,
.image_wrap .img_caption_more,
.image_wrap .img_caption_video,
.image_wrap .img_caption_link{
filter: alpha(opacity=0);
opacity: 0;
background: url(../../images/caption/24.png);
left: 50%;
top: 50%;
-webkit-transform: scale(5);
-moz-transform: scale(5);
-o-transform: scale(5);
-ms-transform: scale(5);
transform: scale(5);
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.image_wrap .img_caption_zoom,.image_wrap:hover .img_caption_zoom {background-position: 0 0; }
.image_wrap .img_caption_more,.image_wrap:hover .img_caption_more{background-position: -48px 0;}
.image_wrap .img_caption_video,.image_wrap:hover .img_caption_video{background-position: -96px 0;}
.image_wrap .img_caption_link,.image_wrap:hover .img_caption_link{background-position: -144px 0;}
.image_wrap:hover .img_caption_zoom,
.image_wrap:hover .img_caption_more,
.image_wrap:hover .img_caption_video,
.image_wrap:hover .img_caption_link{
left: 50%;
top: 50%;
filter: alpha(opacity=100);
opacity: 1;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
/* Button */
.default_button{
border: solid 1px #111111;
color: #FFFFFF;
background: #444444;
}
.default_button:hover,
.default_button:active {
color: #FFFFFF;
background: #00a3a3;
border-color: #004d4d;
}
/*General color scheme
------------------------------------------------------------------------------------------*/
/* Price box title */
.price_box.pb2col .pb_column.pb_active,
.price_box.pb3col .pb_column.pb_active,
.price_box.pb4col .pb_column.pb_active,
.price_box.pb5col .pb_column.pb_active {
border-color:#00a3a3;
box-shadow: 0px 0px 47px #00c7c7;
-moz-box-shadow: 0px 0px 47px #00c7c7;
-webkit-box-shadow: 0px 0px 47px #00c7c7;
}
/* Default color for selected text */
::selection,
::-moz-selection {
background: #008585
}
/* Top search form */
.page_top_details #searchform #s{
border: 1px solid #fff;
background: #fff;
color: #222;
}
.page_top_details #searchform #s:focus{
/* border-color: #008585; */
background: #fff;
color: #222;
}
/* Pagination */
#smk_pagination a{
color:#777;
border-bottom: 3px solid #ddd;
}
#smk_pagination a:hover {
border-color:#008585;
color:#008585;
}
#smk_pagination .active_smk_link {
border-bottom: 3px solid #004d4d;
color:#004d4d;
}
#smk_pagination .disabled_smk_pagination {
border-bottom:3px solid #EBEBEB;
color:#D7D7D7;
}
/* Home clients */
.home_clients .hp_item_grid_client:hover{
border-top-color: #008585;
}
/* Portfolio styles */
.portf_item .pf_icons .pf_icon.img_zoom:hover,
.portf_item .pf_icons .pf_icon.img_info:hover {
background-color: #00a3a3;
}
.portf_item h2:hover{
color: #00c7c7;
}
#portfolio_menu li a:hover {
color: #008585;
}
#portfolio_menu li a.active_cat {
color: #008585;
border-bottom: 1px solid #008585;
}
/* Blog colors */
.blog_article.blog_article_s3 .blog_s3_meta ul.metasingle a:hover {
color: #008585;
}
/* Widgets */
.widget ul li a {
border-bottom: 1px solid #eee;
color: #666;
}
.widget ul li a:hover,
.widget ul li a:focus,
.widget ul li a:active {
border-color:#008585;
color:#008585;
}
.widget ul li.current-menu-item a {
color:#008585;
}
/* Team link color */
.team_member .team_mb_name a:hover{
color: #008585;
}
|
devthuan/ffm
|
templates/fastfox/css/themes/63.css
|
CSS
|
gpl-2.0
| 8,225 |
/*
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "GameObjectAI.h"
#include "CreatureAIImpl.h"
#include "GameEventMgr.h"
enum FireworksShowTypeObjects
{
FIREWORK_SHOW_TYPE_1_RED = 180703,
FIREWORK_SHOW_TYPE_2_RED = 180704,
FIREWORK_SHOW_TYPE_1_RED_BIG = 180707,
FIREWORK_SHOW_TYPE_2_RED_BIG = 180708,
FIREWORK_SHOW_TYPE_1_BLUE = 180720,
FIREWORK_SHOW_TYPE_2_BLUE = 180721,
FIREWORK_SHOW_TYPE_1_BLUE_BIG = 180722,
FIREWORK_SHOW_TYPE_2_BLUE_BIG = 180723,
FIREWORK_SHOW_TYPE_1_GREEN = 180724,
FIREWORK_SHOW_TYPE_2_GREEN_BIG = 180725,
FIREWORK_SHOW_TYPE_1_GREEN_BIG = 180726,
FIREWORK_SHOW_TYPE_2_GREEN = 180727,
FIREWORK_SHOW_TYPE_1_WHITE = 180728,
FIREWORK_SHOW_TYPE_1_WHITE_BIG = 180729,
FIREWORK_SHOW_TYPE_2_WHITE = 180730,
FIREWORK_SHOW_TYPE_2_WHITE_BIG = 180731,
FIREWORK_SHOW_TYPE_1_YELLOW = 180736,
FIREWORK_SHOW_TYPE_1_YELLOW_BIG = 180737,
FIREWORK_SHOW_TYPE_2_YELLOW = 180738,
FIREWORK_SHOW_TYPE_2_YELLOW_BIG = 180739,
FIREWORK_SHOW_TYPE_2_PURPLE = 180740,
FIREWORK_SHOW_TYPE_1_PURPLE_BIG = 180741,
FIREWORK_SHOW_TYPE_2_PURPLE_BIG = 180733
};
enum FireworksMisc
{
SOUND_CHEER_1 = 8574,
SOUND_CHEER_2 = 8573,
SOUND_CHEER_3 = 8572,
SOUND_CHEER_4 = 8571,
EVENT_CHEER = 1,
EVENT_FIRE = 2,
GAME_EVENT_NEW_YEAR = 6
};
enum FireworksZones
{
STRANGLETHORN_VALE = 33, // Booty bay
EVERSONG_WOODS = 3430, // Silvermoon
ORGRIMMAR = 1637,
DUROTAR = 14, // Orgrimmar
UNDERCITY = 1497,
TIRISFAL_GLADES = 85, // Undercity
TELDRASSIL = 141, // Darnassus
EXODAR = 3557,
THUNDERBLUFF = 1638,
DUN_MOROGH = 1, // Ironforge
IRONFORGE = 1537,
STORMWIND = 1519
};
static const std::vector<Position> BootyBayPos =
{
{ -14358.03f, 515.058f, 34.2664f, 3.68265f },
{ -14357.49f, 490.8445f, 39.47329f, 0.9773831f },
{ -14355.49f, 518.5656f, 35.36923f, 4.76475f },
{ -14353.66f, 485.8341f, 36.86639f, 4.886924f },
{ -14376.54f, 487.5282f, 44.47044f, 5.899214f },
{ -14376.66f, 516.6852f, 38.5385f, 2.199115f },
{ -14382.42f, 516.2576f, 37.59617f, 5.846854f },
{ -14389.55f, 485.7437f, 36.32653f, 6.0912f },
{ -14376.76f, 507.9842f, 59.56532f, 0.9773831f },
{ -14358.97f, 502.0223f, 43.82631f, 2.199115f },
{ -14370.77f, 487.4859f, 45.46445f, 4.886924f },
{ -14379.15f, 507.237f, 43.95641f, 6.0912f },
{ -14363.28f, 506.7344f, 41.27156f, 5.899214f },
{ -14374.43f, 496.0701f, 31.31265f, 4.76475f },
{ -14360.71f, 493.6036f, 32.06157f, 5.846854f },
{ -14354.37f, 491.8791f, 39.83374f, 3.68265f },
{ -14371.19f, 505.8404f, 28.75178f, 6.0912f },
{ -14356.57f, 494.1887f, 39.58786f, 3.68265f },
{ -14380.02f, 506.3313f, 59.75512f, 6.0912f },
{ -14389.84f, 503.4612f, 37.37088f, 5.899214f },
{ -14353.64f, 485.4063f, 34.11704f, 4.76475f },
{ -14359.63f, 522.2571f, 31.2866f, 2.199115f },
{ -14374.91f, 491.508f, 40.34925f, 4.886924f },
{ -14351.33f, 506.1898f, 28.69684f, 5.846854f },
{ -14378.1f, 473.5608f, 40.16786f, 0.9773831f }
};
static const std::vector<Position> StormwindPos =
{
{ -8823.592f, 470.316f, 179.2295f, 1.239183f },
{ -8883.005f, 590.1927f, 163.1264f, 0.9773831f },
{ -8919.692f, 482.9097f, 185.6471f, 3.735006f },
{ -8907.228f, 551.7864f, 188.68f, 4.729844f },
{ -8979.651f, 639.3976f, 184.4983f, 3.961899f },
{ -8878.851f, 583.1771f, 166.3018f, 3.700105f },
{ -8937.466f, 517.0521f, 183.7207f, 3.68265f },
{ -8919.247f, 562.2882f, 176.1023f, 3.630291f },
{ -8866.37f, 576.0504f, 157.8798f, 3.47321f },
{ -8957.122f, 517.7014f, 161.3226f, 3.630291f },
{ -8957.857f, 521.934f, 158.9058f, 4.729844f },
{ -8851.988f, 486.5625f, 179.6635f, 4.258607f },
{ -8972.651f, 531.0799f, 176.6744f, 4.886924f },
{ -8986.207f, 560.9792f, 179.1758f, 5.550147f },
{ -8848.866f, 488.8281f, 184.9777f, 3.961899f },
{ -8946.897f, 521.3976f, 193.4021f, 0.9424766f },
{ -8876.854f, 593.6771f, 171.0399f, 0.1396245f },
{ -8828.743f, 463.0382f, 195.7672f, 0.9424766f },
{ -8968.125f, 525.1285f, 181.9304f, 3.054327f },
{ -8952.893f, 629.2743f, 188.2722f, 0.9424766f },
{ -8882.172f, 574.4219f, 181.7124f, 6.0912f },
{ -8980.363f, 546.7934f, 180.4686f, 4.66003f },
{ -8874.944f, 575.5f, 175.7746f, 0.9075702f },
{ -8945.109f, 496.3715f, 153.2825f, 6.073746f },
{ -8953.094f, 513.5521f, 180.9165f, 3.735006f },
{ -8955.02f, 623.7621f, 193.7679f, 0.9424766f },
{ -8977.524f, 644.9097f, 197.926f, 3.961899f },
{ -8985.639f, 653.9809f, 200.0452f, 3.630291f },
{ -8985.639f, 653.9809f, 200.0452f, 3.630291f },
{ -8849.723f, 624.1337f, 144.0357f, 0.8552105f },
{ -8938.404f, 511.8854f, 179.5132f, 0.4712385f },
{ -8815.946f, 571.0833f, 166.8412f, 0.8552105f },
{ -8968.125f, 525.1285f, 180.6735f, 3.054327f },
{ -8887.63f, 582.0261f, 180.219f, 3.787367f },
{ -8962.538f, 541.4132f, 169.8063f, 0.6283169f },
{ -8854.854f, 503.4115f, 194.6336f, 3.630291f },
{ -8810.004f, 589.0504f, 150.2928f, 0.8552105f },
{ -8921.13f, 570.2153f, 186.4456f, 3.857183f },
{ -8957.076f, 538.8073f, 165.0997f, 0.5235979f },
{ -8954.139f, 507.5695f, 178.861f, 3.595379f },
{ -8817.174f, 577.4948f, 152.5639f, 0.8552105f },
{ -8808.778f, 582.6389f, 158.5705f, 0.8552105f },
{ -8898.136f, 566.4236f, 186.5282f, 6.0912f },
{ -8877.205f, 598.0347f, 164.5646f, 0.1396245f },
{ -8815.911f, 460.2049f, 179.4585f, 3.926996f },
{ -8836.877f, 574.1649f, 168.0506f, 0.8552105f },
{ -8883.005f, 590.1927f, 157.0154f, 0.9773831f },
{ -8942.71f, 561.3316f, 198.328f, 3.630291f },
{ -8949.616f, 617.007f, 197.4469f, 3.630291f },
{ -8939.357f, 507.9288f, 155.7625f, 0.6457717f },
{ -8976.667f, 558.6233f, 170.7597f, 5.550147f },
{ -8871.924f, 609.7327f, 151.6364f, 0.8552105f },
{ -8829.264f, 551.5052f, 137.5144f, 0.8552105f },
{ -8859.802f, 567.184f, 162.9909f, 3.47321f },
{ -8864.504f, 604.0816f, 144.7161f, 0.8552105f },
{ -8854.042f, 616.0121f, 146.4188f, 0.8552105f },
{ -8839.778f, 576.8004f, 163.2873f, 0.8552105f },
{ -8863.049f, 497.7986f, 179.2041f, 3.926996f },
{ -8951.743f, 611.4948f, 185.3027f, 3.630291f },
{ -8976.063f, 535.0504f, 178.1283f, 4.66003f },
{ -8937.466f, 517.0521f, 170.561f, 3.68265f },
{ -8940.363f, 490.4288f, 180.8207f, 3.996807f },
{ -8838.177f, 541.6476f, 168.6789f, 0.8552105f },
{ -8825.467f, 450.7708f, 196.6236f, 3.630291f },
{ -8878.851f, 583.1771f, 165.5726f, 3.700105f },
{ -8822.146f, 557.2292f, 147.8244f, 0.8552105f },
{ -8953.243f, 523.8958f, 158.0031f, 3.630291f },
{ -8983.514f, 659.493f, 198.6248f, 3.630291f },
{ -8939.941f, 499.6163f, 158.6714f, 3.944446f },
{ -8925.567f, 542.2158f, 116.1619f, 6.0912f },
{ -8964.125f, 634.6736f, 182.0301f, 0.6283169f },
{ -8930.696f, 491.8021f, 185.6471f, 3.944446f },
{ -8882.172f, 574.4219f, 165.4764f, 6.0912f },
{ -8943.316f, 516.0191f, 155.9438f, 5.846854f },
{ -8871.973f, 589.2795f, 159.1132f, 0.4712385f },
{ -8883.328f, 579.6736f, 172.1912f, 0.6283169f },
{ -8961.998f, 640.1858f, 188.2798f, 0.6283169f },
{ -8912.467f, 506.625f, 175.9382f, 5.846854f },
{ -8843.524f, 481.7865f, 179.664f, 0.9250238f },
{ -8964.986f, 535.2136f, 163.4313f, 4.886924f },
{ -8833.341f, 484.1042f, 192.8578f, 0.6283169f },
{ -8861.382f, 574.7413f, 162.1575f, 3.47321f },
{ -8973.627f, 631.7726f, 192.3904f, 0.6283169f },
{ -8878.851f, 583.1771f, 166.149f, 3.700105f },
{ -8842.842f, 481.2031f, 204.4827f, 0.6283169f },
{ -8902.143f, 527.5035f, 187.1883f, 3.630291f },
{ -8956.248f, 514.2257f, 161.3226f, 3.630291f },
{ -8835.826f, 488.0764f, 179.2099f, 0.9250238f },
{ -8961.319f, 533.3333f, 162.5372f, 3.961899f },
{ -8947.649f, 516.0955f, 163.2207f, 3.68265f },
{ -8949.186f, 504.1337f, 180.9165f, 3.804818f },
{ -8945.564f, 511.5156f, 164.3801f, 5.899214f },
{ -8969.266f, 543.882f, 180.4686f, 4.66003f },
{ -8874.156f, 586.6302f, 161.5547f, 0.9773831f },
{ -8919.748f, 552.2986f, 176.0453f, 3.996807f },
{ -8971.5f, 637.2847f, 197.926f, 0.6283169f },
{ -8965.389f, 525.8906f, 170.2664f, 2.199115f },
{ -8885.1768f, 584.675781f, 141.623886f, 0.62527f },
{ -8880.427734f, 576.678406f, 141.62886f, 0.69819f },
{ -8873.7005f, 570.2418f, 139.33889f, 0.762973f },
{ -8888.692383f, 571.265015f, 120.36886f, 0.601966f },
{ -8870.9571f, 575.9952f, 120.811226f, 0.880780f },
{ -8875.3905f, 582.87028f, 120.81226f, 0.76898f },
{ -8887.0238f, 594.304871f, 120.81226f, 0.700139f },
{ -8887.0238f, 594.3041f, 132.571243f, 5.30658f },
{ -8874.3430f, 584.368164f, 131.409271f, 5.428242f },
{ -8856.23049f, 573.789795f, 131.861237f, 5.707060f },
{ -8881.462891f, 592.391418f, 108.883751f, 0.464518f },
{ -8871.443359f, 582.234802f, 107.030724f, 0.562685f },
{ -8884.809570f, 576.020081f, 100.489868f, 0.621592f },
{ -8871.830078f, 585.984314f, 100.492371f, 0.696206f },
{ -8871.830078f, 585.984314f, 119.252373f, 0.700133f },
{ -8875.578125f, 563.403931f, 104.059372f, 4.521095f },
{ -8896.128906f, 584.406311f, 107.437462f, 2.922810f },
{ -8873.742188f, 599.873718f, 107.512787f, 3.001356f },
{ -8885.817383f, 586.529175f, 98.614265f, 0.437024f },
{ -8872.734375f, 573.338440f, 97.723770f, 1.831103f }
};
static const std::vector<Position> OrgrimmarPos =
{
{ 1609.075f, -4383.707f, 90.23414f, 0.3665176f },
{ 1469.648f, -4371.285f, 113.8313f, 6.073746f },
{ 1391.792f, -4371.f, 165.0406f, 3.630291f },
{ 1405.918f, -4504.896f, 123.1683f, 3.700105f },
{ 1610.016f, -4386.493f, 82.81187f, 3.909541f },
{ 1523.767f, -4385.934f, 100.7948f, 4.572764f },
{ 1486.345f, -4493.087f, 146.1718f, 0.1396245f },
{ 1606.724f, -4414.668f, 121.4687f, 5.550147f },
{ 1647.043f, -4402.644f, 121.7353f, 1.570796f },
{ 1573.078f, -4426.342f, 104.5087f, 5.550147f },
{ 1600.927f, -4367.731f, 87.9886f, 3.874631f },
{ 1558.359f, -4368.33f, 120.0258f, 4.363324f },
{ 1377.49f, -4298.74f, 136.4911f, 5.846854f },
{ 1395.439f, -4403.583f, 170.1769f, 3.68265f },
{ 1394.175f, -4390.438f, 166.5045f, 5.550147f },
{ 1389.752f, -4352.681f, 150.5359f, 3.228859f },
{ 1471.724f, -4393.083f, 129.966f, 3.159062f },
{ 1586.208f, -4334.78f, 104.248f, 2.617989f },
{ 1590.582f, -4338.588f, 110.6812f, 0.2094394f },
{ 1601.163f, -4367.491f, 105.1535f, 0.5410506f },
{ 1493.476f, -4448.524f, 142.9773f, 3.630291f },
{ 1481.592f, -4421.177f, 156.4658f, 0.1396245f },
{ 1382.604f, -4319.927f, 143.5185f, 3.298687f },
{ 1647.483f, -4404.724f, 113.3714f, 2.617989f },
{ 1567.398f, -4423.649f, 108.9948f, 4.206246f },
{ 1560.326f, -4372.816f, 112.5343f, 6.19592f },
{ 1521.741f, -4390.443f, 103.8611f, 5.550147f },
{ 1479.924f, -4424.903f, 156.0753f, 3.054327f },
{ 1387.427f, -4334.854f, 150.2641f, 0.9773831f },
{ 1481.771f, -4466.378f, 138.0009f, 3.47321f },
{ 1390.512f, -4372.778f, 154.748f, 3.071766f },
{ 1605.115f, -4411.217f, 112.0536f, 0.06981169f },
{ 1466.144f, -4341.917f, 140.5263f, 2.548179f },
{ 1479.922f, -4467.948f, 129.9536f, 3.33359f },
{ 1397.09f, -4405.764f, 149.5936f, 2.199115f },
{ 1404.153f, -4497.729f, 121.3236f, 6.0912f },
{ 1493.337f, -4441.268f, 137.3894f, 3.211419f },
{ 1469.385f, -4340.427f, 150.2859f, 2.548179f },
{ 1385.043f, -4317.056f, 145.6198f, 3.194002f },
{ 1472.734f, -4398.983f, 135.9285f, 3.47321f },
{ 1469.135f, -4380.587f, 117.5022f, 0.1396245f },
{ 1389.047f, -4339.42f, 150.2229f, 4.76475f },
{ 1476.245f, -4420.931f, 159.4286f, 3.630291f },
{ 1479.87f, -4421.628f, 161.0234f, 3.054327f },
{ 1391.415f, -4370.76f, 161.9061f, 3.089183f },
{ 1394.175f, -4385.715f, 153.2316f, 5.899214f },
{ 1396.132f, -4411.295f, 161.1071f, 4.66003f },
{ 1403.262f, -4474.733f, 103.9363f, 4.886924f },
{ 1488.257f, -4491.f, 130.442f, 0.03490625f },
{ 1467.707f, -4361.327f, 105.1312f, 3.700105f },
{ 1375.649f, -4366.401f, 152.1661f, 0.1745321f },
{ 1389.922f, -4375.253f, 77.87833f, 6.0912f },
{ 1392.398f, -4379.628f, 172.5377f, 2.199115f },
{ 1394.943f, -4388.257f, 176.3171f, 3.246347f },
{ 1481.833f, -4466.399f, 160.8109f, 3.630291f },
{ 1469.816f, -4366.597f, 120.6296f, 3.159062f },
{ 1379.802f, -4309.967f, 146.3039f, 2.984498f },
{ 1388.002f, -4353.233f, 148.1396f, 5.899214f },
{ 1378.589f, -4296.118f, 144.691f, 5.846854f },
{ 1470.207f, -4395.868f, 133.8257f, 6.073746f },
{ 1406.467f, -4511.327f, 123.2332f, 0.1396245f },
{ 1395.04f, -4390.569f, 167.5848f, 3.228859f },
{ 1480.908f, -4422.219f, 154.6776f, 3.194002f },
{ 1486.033f, -4493.719f, 144.937f, 3.47321f },
{ 1403.845f, -4488.743f, 124.8069f, 3.700105f },
{ 1494.733f, -4446.885f, 140.0633f, 6.248279f },
{ 1481.875f, -4428.431f, 161.3601f, 3.316144f },
{ 1384.299f, -4332.253f, 146.5117f, 3.194002f },
{ 1468.939f, -4346.42f, 143.6888f, 3.054327f },
{ 1393.356f, -4478.347f, 125.5958f, 6.0912f },
{ 1384.672f, -4449.229f, 146.3165f, 4.886924f },
{ 1486.5393f, -4372.5333f, 117.014f, 5.951700f },
{ 1489.1738f, -4415.65091f, 110.5526f, 1.309994f },
{ 1501.63171f, -4454.74668f, 107.716637f, 0.387151f },
{ 1518.3159f, -4438.94873f, 82.9114f, 1.891189f },
{ 1511.754272f, -4423.58203f, 75.781662f, 6.1763f },
{ 1508.1212f, -4399.4312f, 75.781662f, 3.575869f },
{ 1515.1198f, -4356.886719f, 81.859f, 5.87775f },
{ 1553.78795f, -4387.95084f, 72.565178f, 1.372812f },
{ 1549.74023f, -4413.03227f, 74.2219f, 0.42641f },
{ 1528.63644f, -4408.71850f, 118.7224f, 0.23985f },
{ 1532.7171f, -4399.64944f, 50.62704f, 0.13188f },
{ 1509.3391f, -4422.2905f, 55.24475f, 0.1554f },
{ 1501.4160f, -4413.1782f, 42.63250f, 0.347852f },
{ 1499.258179f, -4395.1628f, 42.230198f, 6.02282f },
{ 1485.33571f, -4397.560547f, 51.07567f, 3.2190f },
{ 1495.2693f, -4417.2910f, 50.232471f, 3.31666f },
{ 1498.65912f, -4439.20613f, 49.07176f, 3.7643f },
{ 1523.45699f, -4393.04395f, 39.775066f, 3.71542f },
{ 1536.62665f, -4419.85963f, 40.4508f, 3.46193f },
{ 1497.2632f, -4401.54637f, 33.805511f, 2.60181f },
{ 1497.9363f, -4437.58008f, 32.326393f, 4.96205f },
{ 1493.26253f, -4402.19919f, 59.147816f, 2.2917f }
};
static const std::vector<Position> IronForgePos =
{
{ -5196.038f, -858.4618f, 525.0447f, 6.073746f },
{ -5195.734f, -887.6441f, 534.168f, 3.68265f },
{ -5195.063f, -762.2795f, 510.0929f, 4.66003f },
{ -5164.59f, -858.3264f, 540.0117f, 5.899214f },
{ -5130.776f, -791.1945f, 523.2938f, 5.846854f },
{ -5127.663f, -827.1771f, 534.2573f, 4.76475f },
{ -5227.184f, -754.8802f, 500.0329f, 5.550147f },
{ -5197.655f, -857.8889f, 525.5248f, 2.199115f },
{ -5227.705f, -859.0052f, 513.9084f, 6.0912f },
{ -5227.f, -821.7795f, 471.7424f, 3.700105f },
{ -5131.42f, -791.9445f, 537.8198f, 3.054327f },
{ -5223.59f, -889.6302f, 509.3725f, 4.886924f },
{ -5164.124f, -825.3795f, 525.2161f, 0.9773831f },
{ -5196.168f, -826.6163f, 517.4463f, 2.111848f },
{ -5227.393f, -757.1059f, 501.0704f, 3.47321f },
{ -5192.556f, -784.4583f, 506.9716f, 4.729844f },
{ -5227.965f, -792.184f, 509.1933f, 0.1396245f },
{ -5182.054f, -782.283f, 514.0707f, 4.886924f },
{ -5152.384f, -819.2031f, 508.2252f, 0.9773831f },
{ -5220.162f, -722.941f, 501.573f, 3.700105f },
{ -5218.438f, -879.0486f, 534.1289f, 2.111848f },
{ -5186.096f, -846.5903f, 526.4001f, 3.054327f },
{ -5182.972f, -816.2309f, 522.7172f, 5.550147f },
{ -5172.745f, -854.6077f, 541.5695f, 2.548179f },
{ -5126.936f, -816.5712f, 506.1032f, 4.76475f },
{ -5214.637f, -850.4496f, 524.1501f, 4.729844f },
{ -5156.693f, -818.3021f, 532.9488f, 4.66003f },
{ -5188.997f, -876.8524f, 544.1463f, 6.073746f },
{ -5216.222f, -817.3351f, 498.4872f, 3.630291f },
{ -5190.08f, -758.6545f, 507.9708f, 6.0912f },
{ -5156.724f, -844.0851f, 529.4639f, 5.899214f },
{ -5215.002f, -754.8802f, 488.5055f, 0.1396245f },
{ -5137.646f, -787.2882f, 502.1171f, 5.846854f },
{ -5183.194f, -817.217f, 508.4071f, 3.68265f },
{ -5183.191f, -848.6163f, 518.0361f, 2.199115f },
{ -5215.972f, -785.0452f, 494.1193f, 3.47321f },
{ -5117.396f, -791.4796f, 483.5854f, 6.0912f },
{ -5153.132f, -781.2309f, 539.7031f, 5.899214f },
{ -5209.993f, -710.1337f, 501.9293f, 5.846854f },
{ -5172.809f, -848.1094f, 520.4458f, 6.0912f },
{ -5120.552f, -812.3004f, 547.9608f, 3.68265f },
{ -5142.92f, -811.507f, 526.748f, 4.886924f },
{ -5208.391f, -773.4583f, 497.451f, 4.729844f },
{ -5181.903f, -779.1979f, 518.5895f, 0.9773831f },
{ -5208.097f, -843.934f, 514.2054f, 3.47321f },
{ -5118.309f, -783.3246f, 545.3275f, 2.199115f },
{ -5213.969f, -715.6684f, 493.5344f, 6.073746f },
{ -5211.384f, -872.493f, 523.3142f, 0.1396245f },
{ -5215.563f, -812.7205f, 501.1313f, 2.548179f },
{ -5159.971f, -819.0695f, 523.9502f, 5.550147f },
{ -5243.21f, -741.7934f, 479.6208f, 2.111848f },
{ -5158.577f, -784.243f, 515.7791f, 3.054327f },
{ -5210.179f, -809.2413f, 507.136f, 3.630291f },
{ -5182.26f, -818.6476f, 519.5022f, 4.66003f },
{ -5178.493f, -870.8143f, 539.2921f, 3.700105f },
{ -5206.622f, -741.5938f, 511.1593f, 4.76475f },
{ -5194.976f, -759.9896f, 517.6288f, 3.630291f }
};
static const std::vector<Position> SilvermoonPos =
{
{ 9466.583f, -7307.326f, 107.8366f, 0.1047193f },
{ 9411.616f, -7322.223f, 79.95399f, 2.722713f },
{ 9472.98f, -7276.879f, 111.8719f, 6.056293f },
{ 9403.265f, -7283.608f, 108.6991f, 3.106652f },
{ 9426.45f, -7221.809f, 95.899f, 3.612838f },
{ 9410.442f, -7283.999f, 113.0489f, 3.106652f },
{ 9398.225f, -7284.489f, 81.34821f, 3.019413f },
{ 9400.401f, -7268.281f, 114.684f, 3.228859f },
{ 9478.615f, -7259.143f, 109.0896f, 5.777041f },
{ 9480.074f, -7163.523f, 113.2669f, 0.1396245f },
{ 9482.511f, -7119.089f, 95.79392f, 6.021387f },
{ 9407.579f, -7277.173f, 145.9511f, 3.159062f },
{ 9399.398f, -7323.894f, 106.2334f, 2.617989f },
{ 9395.489f, -7278.119f, 77.25965f, 3.106652f },
{ 9407.703f, -7330.93f, 97.46037f, 2.565632f },
{ 9408.553f, -7254.359f, 103.7934f, 3.455756f },
{ 9480.151f, -7135.254f, 120.9287f, 6.19592f },
{ 9412.958f, -7276.931f, 107.8171f, 3.141593f },
{ 9475.104f, -7306.728f, 116.2541f, 0.1745321f },
{ 9464.988f, -7319.295f, 101.1637f, 0.2617982f },
{ 9472.38f, -7267.314f, 140.3056f, 5.93412f },
{ 9410.978f, -7300.815f, 109.2923f, 2.583081f },
{ 9405.042f, -7301.033f, 124.4924f, 2.967041f },
{ 9403.106f, -7309.054f, 103.702f, 2.984498f },
{ 9464.217f, -7350.079f, 131.7602f, 0.5759573f },
{ 9456.133f, -7348.024f, 104.9382f, 0.383971f },
{ 9411.794f, -7285.174f, 101.2357f, 3.089183f },
{ 9411.597f, -7266.42f, 102.0371f, 3.263772f },
{ 9478.836f, -7127.272f, 95.90057f, 6.143561f },
{ 9481.063f, -7136.337f, 101.3669f, 0.01745246f },
{ 9398.232f, -7329.835f, 85.74606f, 2.775069f },
{ 9399.838f, -7268.37f, 72.05019f, 3.211419f },
{ 9409.207f, -7241.094f, 85.7521f, 3.368496f },
{ 9465.259f, -7310.388f, 113.2353f, 0.6283169f },
{ 9487.643f, -7155.167f, 124.4381f, 0.122173f },
{ 9431.971f, -7222.501f, 95.89851f, 3.455756f },
{ 9393.978f, -7278.168f, 71.72367f, 3.124123f },
{ 9487.966f, -7268.014f, 119.8879f, 5.829401f },
{ 9404.565f, -7330.906f, 90.92167f, 2.740162f },
{ 9465.2f, -7313.238f, 124.9027f, 0.2268925f },
{ 9470.827f, -7304.245f, 135.3172f, 6.265733f },
{ 9403.582f, -7255.257f, 107.5193f, 3.298687f },
{ 9399.23f, -7310.893f, 80.78027f, 2.879789f },
{ 9472.535f, -7267.201f, 112.1708f, 6.03884f },
{ 9491.937f, -7154.478f, 97.61007f, 0.05235888f },
{ 9412.064f, -7278.493f, 116.0459f, 3.106652f },
{ 9369.768f, -7276.374f, 14.24026f, 6.0912f },
{ 9410.102f, -7295.561f, 143.4681f, 3.019413f },
{ 9484.801f, -7131.789f, 81.00427f, 6.161013f },
{ 9411.763f, -7266.338f, 107.3137f, 3.106652f },
{ 9407.249f, -7253.171f, 115.6959f, 3.316144f },
{ 9465.064f, -7316.58f, 144.7163f, 0.2967052f },
{ 9411.466f, -7252.686f, 113.9839f, 3.33359f },
{ 9474.942f, -7260.846f, 125.8512f, 5.969027f },
{ 9485.356f, -7110.373f, 104.1972f, 6.03884f },
{ 9402.48f, -7333.202f, 107.0458f, 2.460913f },
{ 9404.987f, -7279.173f, 133.3515f, 2.949595f },
{ 9476.116f, -7270.055f, 105.0233f, 6.003934f },
{ 9470.456f, -7300.805f, 107.3014f, 0.087266f },
{ 9434.106f, -7236.905f, 133.1817f, 3.368496f },
{ 9416.494f, -7325.862f, 113.1137f, 2.652894f },
{ 9406.013f, -7302.038f, 109.1291f, 2.740162f },
{ 9473.886f, -7256.887f, 108.9899f, 5.829401f },
{ 9430.171f, -7231.706f, 114.6874f, 3.42085f },
{ 9404.366f, -7275.19f, 144.4704f, 3.071766f },
{ 9411.504f, -7288.202f, 112.2664f, 2.844883f }
};
static const std::vector<Position> ExodarPos =
{
{ -3992.465f, -11843.86f, 186.4043f, 2.199115f },
{ -3948.378f, -11854.06f, 135.6206f, 3.47321f },
{ -3918.684f, -11840.53f, 216.565f, 4.886924f },
{ -3946.1f, -11854.03f, 131.2059f, 6.0912f },
{ -3966.864f, -11851.99f, 106.2717f, 2.548179f },
{ -3994.082f, -11855.4f, 66.14954f, 4.32842f },
{ -3989.288f, -11846.68f, 147.7923f, 3.700105f },
{ -3974.271f, -11849.3f, 183.4967f, 0.9773831f },
{ -3943.34f, -11850.36f, 191.2153f, 5.846854f },
{ -3923.543f, -11851.16f, 93.1925f, 3.054327f },
{ -3990.212f, -11844.83f, 89.08578f, 2.111848f },
{ -3977.315f, -11848.61f, 128.4479f, 3.700105f },
{ -3972.831f, -11850.72f, 89.65628f, 2.548179f },
{ -3946.937f, -11851.44f, 192.1654f, 2.199115f },
{ -3937.843f, -11856.82f, 80.51583f, 4.66003f },
{ -3954.331f, -11851.98f, 81.24915f, 3.054327f },
{ -3937.817f, -11853.64f, 121.1544f, 3.47321f },
{ -3967.367f, -11851.36f, 123.7478f, 4.729844f },
{ -3986.625f, -11847.29f, 142.0192f, 6.0912f },
{ -3990.369f, -11844.75f, 94.17735f, 6.073746f },
{ -3938.356f, -11850.21f, 200.6413f, 3.68265f },
{ -3954.939f, -11852.58f, 184.5983f, 5.899214f },
{ -3988.003f, -11846.72f, 73.19949f, 6.0912f },
{ -3896.356f, -11844.68f, 148.2895f, 5.899214f },
{ -3971.118f, -11850.72f, 137.1919f, 6.073746f },
{ -3930.919f, -11853.74f, 138.6459f, 0.9773831f },
{ -3984.946f, -11844.98f, 164.378f, 4.66003f },
{ -3943.503f, -11854.65f, 145.232f, 3.630291f },
{ -3812.792f, -11807.49f, 135.9212f, 3.700105f },
{ -3943.854f, -11854.62f, 163.0852f, 5.550147f },
{ -3957.711f, -11850.8f, 147.1301f, 3.68265f },
{ -3949.376f, -11848.43f, 146.4466f, 2.199115f },
{ -4014.848f, -11815.58f, 130.2189f, 4.729844f },
{ -4012.328f, -11821.78f, 92.57595f, 6.073746f },
{ -4025.119f, -11794.49f, 183.6754f, 4.76475f },
{ -4031.543f, -11791.47f, 78.31419f, 4.66003f },
{ -4019.754f, -11805.57f, 129.9788f, 3.630291f },
{ -4009.46f, -11824.12f, 126.7007f, 0.1396245f },
{ -4049.115f, -11781.37f, 197.9942f, 3.68265f },
{ -4006.23f, -11830.18f, 184.4535f, 5.899214f },
{ -4017.271f, -11814.06f, 73.86016f, 2.111848f },
{ -4018.511f, -11807.98f, 179.3607f, 4.450591f },
{ -4038.572f, -11767.11f, 191.1657f, 4.76475f },
{ -4018.321f, -11808.37f, 178.2087f, 0.9773831f },
{ -4013.852f, -11817.62f, 126.2276f, 4.886924f },
{ -4028.476f, -11782.85f, 100.8544f, 0.1396245f },
{ -4006.938f, -11821.57f, 81.11591f, 5.550147f },
{ -4018.111f, -11808.96f, 113.2876f, 3.630291f },
{ -4069.263f, -11755.89f, 133.3362f, 0.1396245f },
{ -4041.02f, -11757.23f, 139.8532f, 5.846854f },
{ -4012.13f, -11814.23f, 165.8398f, 3.054327f },
{ -4028.264f, -11781.04f, 135.2486f, 6.0912f },
{ -4025.534f, -11790.81f, 164.8259f, 2.548179f },
{ -4015.083f, -11815.16f, 147.3407f, 4.886924f },
{ -4011.046f, -11818.31f, 141.9634f, 4.76475f },
{ -4043.675f, -11746.47f, 136.9332f, 3.47321f },
{ -4013.666f, -11817.91f, 169.5565f, 2.111848f },
{ -4036.461f, -11783.4f, 142.8152f, 4.729844f }
};
static const std::vector<Position> ThunderBluffPos =
{
{ -1234.804f, -19.72239f, 206.5436f, 0.1396245f },
{ -1244.442f, -35.88308f, 206.82f, 4.729844f },
{ -1239.212f, -11.25857f, 208.6352f, 3.700105f },
{ -1217.165f, -15.58898f, 207.4553f, 3.68265f },
{ -1229.332f, -6.54617f, 208.2537f, 2.548179f },
{ -1227.353f, -14.30225f, 206.6192f, 3.054327f },
{ -1234.8f, -14.12402f, 208.0964f, 6.0912f },
{ -1246.791f, -38.59223f, 206.846f, 6.073746f },
{ -1229.818f, -6.788249f, 209.4552f, 4.886924f },
{ -1223.867f, -10.67551f, 205.7558f, 0.9773831f },
{ -1229.833f, -6.403429f, 208.6842f, 4.76475f },
{ -1239.199f, -23.20622f, 207.0188f, 3.47321f },
{ -1246.258f, -37.36089f, 208.2598f, 2.199115f },
{ -1223.363f, -12.2462f, 201.3805f, 4.66003f },
{ -1218.116f, -16.37305f, 199.9185f, 5.550147f },
{ -1239.709f, -42.34294f, 204.2466f, 2.111848f },
{ -1219.295f, -12.87424f, 206.2387f, 5.899214f },
{ -1251.241f, -33.18164f, 209.7986f, 3.630291f },
{ -1219.549f, -12.32769f, 207.9862f, 3.47321f },
{ -1251.181f, -34.52919f, 206.8795f, 4.66003f },
{ -1235.567f, -15.02116f, 205.3759f, 2.199115f },
{ -1241.148f, -41.8049f, 205.8436f, 0.1396245f },
{ -1241.41f, -23.09136f, 206.5933f, 3.054327f },
{ -1235.885f, -19.49116f, 206.4422f, 3.68265f },
{ -1234.823f, -13.99685f, 210.1406f, 6.073746f },
{ -1220.117f, -10.93815f, 204.8297f, 4.76475f },
{ -1219.087f, -6.230252f, 206.5717f, 5.899214f },
{ -1235.053f, -20.39225f, 206.5732f, 3.630291f },
{ -1239.364f, -22.23714f, 207.2047f, 4.886924f },
{ -1245.448f, -37.35639f, 208.0733f, 3.700105f },
{ -1222.941f, -10.68441f, 208.3044f, 0.9773831f },
{ -1238.765f, -11.7156f, 203.8905f, 2.111848f },
{ -1251.638f, -34.5931f, 207.4821f, 6.0912f },
{ -1229.332f, -6.54617f, 205.5314f, 4.729844f },
{ -1245.196f, -37.02111f, 208.2277f, 5.550147f },
{ -1235.227f, -19.88525f, 206.9543f, 2.548179f },
{ -1249.993f, -35.97727f, 206.9852f, 5.846854f },
{ -1238.741f, -11.55127f, 216.4102f, 4.76475f },
{ -1242.702f, -23.95698f, 215.8784f, 2.199115f },
{ -1223.998f, -11.75629f, 187.3124f, 6.0912f },
{ -1220.138f, -16.90701f, 218.7182f, 2.111848f },
{ -1239.351f, -23.36654f, 218.1057f, 5.550147f },
{ -1222.544f, -11.58713f, 218.9956f, 3.630291f },
{ -1234.379f, -19.82167f, 211.3573f, 5.899214f },
{ -1224.649f, -16.73172f, 217.2839f, 6.073746f },
{ -1219.856f, -11.69358f, 218.5711f, 0.1396245f },
{ -1223.967f, -8.415148f, 219.2347f, 3.47321f },
{ -1252.266f, -33.21897f, 215.823f, 3.68265f },
{ -1244.304f, -41.49599f, 214.7235f, 3.700105f },
{ -1245.102f, -34.69542f, 215.4592f, 4.886924f },
{ -1239.761f, -41.99474f, 211.7772f, 6.0912f },
{ -1219.803f, -11.18414f, 219.6471f, 4.729844f },
{ -1219.832f, -12.19803f, 219.4899f, 5.846854f },
{ -1236.825f, -18.4617f, 220.2076f, 4.66003f },
{ -1239.635f, -11.55973f, 220.694f, 2.548179f },
{ -1233.765f, -15.5765f, 216.1068f, 3.054327f },
{ -1233.56f, -15.80257f, 215.6199f, 0.9773831f },
{ -1240.617f, -41.39486f, 205.0362f, 5.846854f }
};
static const std::vector<Position> UndercityPos =
{
{ 1850.231f, 257.0156f, 124.1743f, 4.729844f },
{ 1863.302f, 193.9063f, 114.5829f, 0.9773831f },
{ 1851.997f, 212.7726f, 127.959f, 5.550147f },
{ 1862.474f, 288.1528f, 118.4504f, 6.0912f },
{ 1851.906f, 267.6267f, 131.5442f, 3.054327f },
{ 1868.905f, 323.2587f, 131.801f, 0.1396245f },
{ 1849.677f, 196.5052f, 119.4152f, 2.548179f },
{ 1870.382f, 155.8438f, 135.8888f, 5.846854f },
{ 1863.309f, 211.9219f, 117.2065f, 5.899214f },
{ 1849.877f, 215.7413f, 120.1931f, 6.073746f },
{ 1864.762f, 170.5399f, 108.2692f, 4.76475f },
{ 1839.986f, 288.4306f, 126.1348f, 3.47321f },
{ 1875.91f, 230.566f, 125.1612f, 2.199115f },
{ 1854.146f, 238.7622f, 131.7162f, 4.66003f },
{ 1863.307f, 264.4583f, 123.374f, 4.886924f },
{ 1871.578f, 266.8681f, 108.0443f, 4.66003f },
{ 1836.901f, 185.5868f, 113.362f, 3.630291f },
{ 1871.545f, 191.2622f, 105.8294f, 6.073746f },
{ 1863.307f, 211.816f, 114.3906f, 4.76475f },
{ 1841.543f, 205.1754f, 102.9691f, 3.47321f },
{ 1843.304f, 273.4757f, 104.6566f, 6.0912f },
{ 1870.818f, 167.0938f, 126.3066f, 4.729844f },
{ 1840.653f, 227.6319f, 106.8095f, 0.1396245f },
{ 1863.299f, 282.1806f, 110.9902f, 2.199115f },
{ 1875.688f, 230.5278f, 112.7081f, 3.054327f },
{ 1872.264f, 311.1458f, 119.7756f, 3.68265f },
{ 1871.248f, 297.1684f, 113.6078f, 5.550147f },
{ 1863.293f, 186.4896f, 114.6143f, 5.846854f },
{ 1838.384f, 252.3264f, 103.8479f, 3.700105f },
{ 1886.804f, 166.3976f, 125.2679f, 2.111848f },
{ 1863.363f, 237.5417f, 125.3641f, 0.9773831f },
{ 1863.307f, 267.875f, 113.7794f, 5.899214f },
{ 1845.602f, 299.4445f, 120.9578f, 4.886924f },
{ 1871.884f, 217.2656f, 108.2966f, 2.548179f },
{ 1867.459f, 240.2357f, 106.0639f, 6.0912f },
{ 1863.326f, 298.4879f, 121.1103f, 3.054327f },
{ 1844.776f, 287.776f, 131.6692f, 4.76475f },
{ 1842.595f, 299.8854f, 132.9048f, 5.846854f },
{ 1843.754f, 233.0833f, 122.607f, 3.68265f },
{ 1865.563f, 238.7674f, 127.128f, 5.550147f },
{ 1863.302f, 282.6076f, 117.6718f, 2.548179f },
{ 1850.063f, 218.7344f, 116.5234f, 4.886924f },
{ 1852.528f, 257.8333f, 125.5587f, 5.899214f },
{ 1870.385f, 321.809f, 123.7424f, 4.66003f },
{ 1864.694f, 167.474f, 111.3632f, 0.1396245f },
{ 1846.231f, 194.2656f, 108.0038f, 3.700105f },
{ 1876.434f, 227.1129f, 116.7266f, 4.729844f },
{ 1839.993f, 245.0399f, 120.8441f, 2.199115f },
{ 1864.042f, 204.4774f, 105.6403f, 3.630291f },
{ 1875.594f, 246.9271f, 110.0379f, 2.111848f },
{ 1850.892f, 273.6059f, 133.6044f, 0.9773831f },
{ 1863.3f, 186.2188f, 118.3104f, 3.47321f },
{ 1851.578f, 203.2604f, 118.5638f, 6.0912f },
{ 1863.307f, 259.8038f, 116.5421f, 6.073746f },
{ 1877.592f, 247.3872f, 128.022f, 3.68265f },
{ 1850.288f, 267.309f, 125.0537f, 3.630291f }
};
static const std::vector<Position> DarnassusPos =
{
{ 8578.888f, 975.2604f, 42.48742f, 5.846854f },
{ 8574.236f, 944.2083f, 44.71943f, 4.76475f },
{ 8517.067f, 986.0851f, 66.32562f, 4.729844f },
{ 8553.734f, 780.0504f, 63.21661f, 4.886924f },
{ 8537.763f, 877.8924f, 76.7791f, 3.054327f },
{ 8572.691f, 814.7379f, 72.4253f, 3.68265f },
{ 8572.691f, 814.7379f, 72.4253f, 3.68265f },
{ 8494.191f, 943.868f, 59.0681f, 6.073746f },
{ 8536.576f, 873.7222f, 45.29478f, 0.1396245f },
{ 8550.191f, 850.7222f, 57.6362f, 3.700105f },
{ 8554.281f, 875.8316f, 48.10747f, 5.550147f },
{ 8590.731f, 846.9427f, 56.89664f, 2.199115f },
{ 8519.5f, 949.7708f, 63.29575f, 3.630291f },
{ 8508.24f, 838.3646f, 77.00415f, 4.66003f },
{ 8588.622f, 912.0434f, 49.60857f, 0.9773831f },
{ 8538.786f, 820.7361f, 67.0003f, 6.0912f },
{ 8488.077f, 983.2379f, 59.87747f, 2.111848f },
{ 8494.68f, 911.783f, 72.29862f, 2.548179f },
{ 8556.297f, 920.9479f, 42.13089f, 3.47321f },
{ 8571.629f, 880.1511f, 53.78056f, 5.899214f },
{ 8544.278f, 885.059f, 70.3073f, 0.1396245f },
{ 8551.224f, 947.6059f, 60.74737f, 6.0912f },
{ 8586.716f, 913.4774f, 42.5911f, 4.76475f },
{ 8617.442f, 917.658f, 41.92455f, 4.886924f },
{ 8519.375f, 917.842f, 74.22758f, 2.111848f },
{ 8550.322f, 910.9809f, 52.84513f, 3.700105f },
{ 8582.255f, 848.0608f, 53.87154f, 5.899214f },
{ 8547.279f, 964.1684f, 45.09663f, 5.550147f },
{ 8581.158f, 881.2344f, 54.83494f, 0.9773831f },
{ 8550.932f, 817.2396f, 60.80384f, 3.630291f },
{ 8550.214f, 787.1684f, 66.42948f, 4.729844f },
{ 8583.88f, 948.4114f, 41.32378f, 5.846854f },
{ 8550.997f, 848.8594f, 70.56313f, 3.47321f },
{ 8517.45f, 879.5555f, 83.80603f, 6.073746f },
{ 8558.55f, 838.934f, 56.89937f, 4.66003f },
{ 8617.526f, 851.5955f, 37.39491f, 3.68265f },
{ 8579.229f, 911.8906f, 44.37334f, 3.054327f },
{ 8581.771f, 817.0295f, 30.07061f, 2.199115f },
{ 8514.054f, 848.6059f, 59.20383f, 2.548179f },
{ 8570.65f, 885.1719f, 59.11485f, 2.548179f },
{ 8576.803f, 814.3611f, 50.15007f, 4.66003f },
{ 8697.891f, 991.0841f, 39.18531f, 6.0912f },
{ 8547.403f, 974.4879f, 63.7893f, 5.846854f },
{ 8553.929f, 853.6476f, 84.47609f, 0.1396245f },
{ 8507.603f, 878.8854f, 70.23988f, 5.899214f },
{ 8570.95f, 854.1406f, 65.7302f, 3.054327f },
{ 8560.618f, 777.342f, 79.87446f, 4.886924f },
{ 8542.07f, 852.0174f, 64.99033f, 3.700105f },
{ 8514.364f, 940.0868f, 64.65899f, 4.76475f },
{ 8526.2f, 848.8542f, 63.1242f, 2.199115f },
{ 8571.85f, 913.1511f, 43.11662f, 6.073746f },
{ 8591.914f, 901.6493f, 26.83536f, 5.550147f },
{ 8539.892f, 914.3368f, 45.99331f, 3.630291f },
{ 8578.143f, 948.3264f, 62.56763f, 2.111848f },
{ 8539.493f, 887.2274f, 79.56437f, 3.47321f },
{ 8538.561f, 951.6632f, 69.08958f, 4.729844f },
{ 8523.006f, 907.7413f, 72.85262f, 0.9773831f },
{ 8520.907f, 813.0208f, 81.70242f, 3.68265f },
{ 8554.825f, 813.0746f, 78.88226f, 6.0912f }
};
static const std::unordered_map<uint32, std::vector<Position> const&> pos =
{
{ STRANGLETHORN_VALE, BootyBayPos },
{ STORMWIND, StormwindPos },
{ ORGRIMMAR, OrgrimmarPos },
{ DUROTAR, OrgrimmarPos },
{ DUN_MOROGH, IronForgePos },
{ IRONFORGE, IronForgePos },
{ EVERSONG_WOODS, SilvermoonPos },
{ EXODAR, ExodarPos },
{ THUNDERBLUFF, ThunderBluffPos },
{ UNDERCITY, UndercityPos },
{ TIRISFAL_GLADES, UndercityPos },
{ TELDRASSIL, DarnassusPos }
};
class go_cheer_speaker : public GameObjectScript
{
public:
go_cheer_speaker() : GameObjectScript("go_cheer_speaker") { }
struct go_cheer_speakerAI : public GameObjectAI
{
go_cheer_speakerAI(GameObject* go) : GameObjectAI(go)
{
_started = false;
_big = true;
}
uint32 CheerPicker()
{
uint32 newid = RAND(
SOUND_CHEER_1,
SOUND_CHEER_2,
SOUND_CHEER_3,
SOUND_CHEER_4
);
return newid;
}
uint32 FireworksPicker()
{
uint32 newid = RAND(
FIREWORK_SHOW_TYPE_1_RED,
FIREWORK_SHOW_TYPE_2_RED,
FIREWORK_SHOW_TYPE_1_RED_BIG,
FIREWORK_SHOW_TYPE_2_RED_BIG,
FIREWORK_SHOW_TYPE_1_BLUE,
FIREWORK_SHOW_TYPE_2_BLUE,
FIREWORK_SHOW_TYPE_1_BLUE_BIG,
FIREWORK_SHOW_TYPE_2_BLUE_BIG,
FIREWORK_SHOW_TYPE_1_GREEN,
FIREWORK_SHOW_TYPE_2_GREEN_BIG,
FIREWORK_SHOW_TYPE_1_GREEN_BIG,
FIREWORK_SHOW_TYPE_2_GREEN,
FIREWORK_SHOW_TYPE_1_WHITE,
FIREWORK_SHOW_TYPE_1_WHITE_BIG,
FIREWORK_SHOW_TYPE_2_WHITE,
FIREWORK_SHOW_TYPE_2_WHITE_BIG,
FIREWORK_SHOW_TYPE_1_YELLOW,
FIREWORK_SHOW_TYPE_1_YELLOW_BIG,
FIREWORK_SHOW_TYPE_2_YELLOW,
FIREWORK_SHOW_TYPE_2_YELLOW_BIG,
FIREWORK_SHOW_TYPE_2_PURPLE,
FIREWORK_SHOW_TYPE_1_PURPLE_BIG,
FIREWORK_SHOW_TYPE_2_PURPLE_BIG
);
return newid;
}
uint32 FireworksBIGOnlyPicker()
{
uint32 newid = RAND(
FIREWORK_SHOW_TYPE_1_RED_BIG,
FIREWORK_SHOW_TYPE_2_RED_BIG,
FIREWORK_SHOW_TYPE_1_BLUE_BIG,
FIREWORK_SHOW_TYPE_2_BLUE_BIG,
FIREWORK_SHOW_TYPE_2_GREEN_BIG,
FIREWORK_SHOW_TYPE_1_GREEN_BIG,
FIREWORK_SHOW_TYPE_1_WHITE_BIG,
FIREWORK_SHOW_TYPE_2_WHITE_BIG,
FIREWORK_SHOW_TYPE_1_YELLOW_BIG,
FIREWORK_SHOW_TYPE_2_YELLOW_BIG,
FIREWORK_SHOW_TYPE_1_PURPLE_BIG,
FIREWORK_SHOW_TYPE_2_PURPLE_BIG
);
return newid;
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
time_t time = sWorld->GetGameTime();
tm localTm;
localtime_r(&time, &localTm);
// Start
if (((localTm.tm_min == 0 && localTm.tm_sec == 0) && !_started && IsHolidayActive(HOLIDAY_FIREWORKS_SPECTACULAR)) ||
((localTm.tm_hour == 0 && localTm.tm_min == 0 && localTm.tm_sec == 0) && !_started && IsEventActive(GAME_EVENT_NEW_YEAR)))
{
_events.ScheduleEvent(EVENT_CHEER, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_started = true;
}
// Event is active
if ((localTm.tm_min >= 0 && localTm.tm_sec >= 1 && localTm.tm_min <= 9 && localTm.tm_sec <= 59) && !_started && IsHolidayActive(HOLIDAY_FIREWORKS_SPECTACULAR))
{
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_started = true;
}
// Stop
if ((localTm.tm_min == 10 && localTm.tm_sec == 0) || (localTm.tm_min == 10 && localTm.tm_sec == 0 && localTm.tm_hour == 0 && _started == true))
{
_started = false;
_events.ScheduleEvent(EVENT_CHEER, Seconds(1));
_events.CancelEvent(EVENT_FIRE);
}
// New Year (Only!) - One more big bang!
if ((localTm.tm_min == 10 && localTm.tm_sec == 30 && localTm.tm_hour == 0) && IsEventActive(GAME_EVENT_NEW_YEAR) && _big == true)
{
_big = false;
_events.ScheduleEvent(EVENT_CHEER, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
_events.ScheduleEvent(EVENT_FIRE, Seconds(1));
}
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_CHEER:
{
go->PlayDistanceSound(CheerPicker());
break;
}
case EVENT_FIRE:
{
auto it = pos.find(go->GetZoneId());
if (it != pos.end())
{
Position const& rndpos = Trinity::Containers::SelectRandomContainerElement(it->second);
float rndrot = frand(-1.0000000f, 1.0000000f);
float rndrot2 = frand(-1.0000000f, 1.0000000f);
if (_big)
{
if (GameObject* firework = go->SummonGameObject(FireworksBIGOnlyPicker(), rndpos, G3D::Quat(0.f, 0.f, rndrot, rndrot2), 300))
{
firework->SetRespawnTime(0);
firework->Delete();
}
}
else
{
if (GameObject* firework = go->SummonGameObject(FireworksPicker(), rndpos, G3D::Quat(0.f, 0.f, rndrot, rndrot2), 300))
{
firework->SetRespawnTime(0);
firework->Delete();
}
}
}
if (_started == true)
_events.ScheduleEvent(EVENT_FIRE, Seconds(1), Seconds(2));
break;
}
default:
break;
}
}
}
private:
EventMap _events;
bool _started;
bool _big;
};
GameObjectAI* GetAI(GameObject* go) const override
{
return new go_cheer_speakerAI(go);
}
};
void AddSC_event_fireworks()
{
new go_cheer_speaker();
}
|
codie72/TrinityCore
|
src/server/scripts/Events/fireworks_show.cpp
|
C++
|
gpl-2.0
| 44,181 |
/* linux/drivers/media/video/s5p-jpeg/jpeg-core.c
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd.
* http://www.samsung.com
*
* Author: Andrzej Pietrasiewicz <[email protected]>
*
* 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/clk.h>
#include <linux/err.h>
#include <linux/gfp.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <media/v4l2-mem2mem.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-core.h>
#include <media/videobuf2-dma-contig.h>
#include "jpeg-core.h"
#include "jpeg-hw.h"
static struct s5p_jpeg_fmt formats_enc[] = {
{
.name = "JPEG JFIF",
.fourcc = V4L2_PIX_FMT_JPEG,
.colplanes = 1,
.types = MEM2MEM_CAPTURE,
},
{
.name = "YUV 4:2:2 packed, YCbYCr",
.fourcc = V4L2_PIX_FMT_YUYV,
.depth = 16,
.colplanes = 1,
.types = MEM2MEM_OUTPUT,
},
{
.name = "RGB565",
.fourcc = V4L2_PIX_FMT_RGB565,
.depth = 16,
.colplanes = 1,
.types = MEM2MEM_OUTPUT,
},
};
#define NUM_FORMATS_ENC ARRAY_SIZE(formats_enc)
static struct s5p_jpeg_fmt formats_dec[] = {
{
.name = "YUV 4:2:0 planar, YCbCr",
.fourcc = V4L2_PIX_FMT_YUV420,
.depth = 12,
.colplanes = 3,
.h_align = 4,
.v_align = 4,
.types = MEM2MEM_CAPTURE,
},
{
.name = "YUV 4:2:2 packed, YCbYCr",
.fourcc = V4L2_PIX_FMT_YUYV,
.depth = 16,
.colplanes = 1,
.h_align = 4,
.v_align = 3,
.types = MEM2MEM_CAPTURE,
},
{
.name = "JPEG JFIF",
.fourcc = V4L2_PIX_FMT_JPEG,
.colplanes = 1,
.types = MEM2MEM_OUTPUT,
},
};
#define NUM_FORMATS_DEC ARRAY_SIZE(formats_dec)
static const unsigned char qtbl_luminance[4][64] = {
{/* level 1 - high quality */
8, 6, 6, 8, 12, 14, 16, 17,
6, 6, 6, 8, 10, 13, 12, 15,
6, 6, 7, 8, 13, 14, 18, 24,
8, 8, 8, 14, 13, 19, 24, 35,
12, 10, 13, 13, 20, 26, 34, 39,
14, 13, 14, 19, 26, 34, 39, 39,
16, 12, 18, 24, 34, 39, 39, 39,
17, 15, 24, 35, 39, 39, 39, 39
},
{/* level 2 */
12, 8, 8, 12, 17, 21, 24, 23,
8, 9, 9, 11, 15, 19, 18, 23,
8, 9, 10, 12, 19, 20, 27, 36,
12, 11, 12, 21, 20, 28, 36, 53,
17, 15, 19, 20, 30, 39, 51, 59,
21, 19, 20, 28, 39, 51, 59, 59,
24, 18, 27, 36, 51, 59, 59, 59,
23, 23, 36, 53, 59, 59, 59, 59
},
{/* level 3 */
16, 11, 11, 16, 23, 27, 31, 30,
11, 12, 12, 15, 20, 23, 23, 30,
11, 12, 13, 16, 23, 26, 35, 47,
16, 15, 16, 23, 26, 37, 47, 64,
23, 20, 23, 26, 39, 51, 64, 64,
27, 23, 26, 37, 51, 64, 64, 64,
31, 23, 35, 47, 64, 64, 64, 64,
30, 30, 47, 64, 64, 64, 64, 64
},
{/*level 4 - low quality */
20, 16, 25, 39, 50, 46, 62, 68,
16, 18, 23, 38, 38, 53, 65, 68,
25, 23, 31, 38, 53, 65, 68, 68,
39, 38, 38, 53, 65, 68, 68, 68,
50, 38, 53, 65, 68, 68, 68, 68,
46, 53, 65, 68, 68, 68, 68, 68,
62, 65, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68
}
};
static const unsigned char qtbl_chrominance[4][64] = {
{/* level 1 - high quality */
9, 8, 9, 11, 14, 17, 19, 24,
8, 10, 9, 11, 14, 13, 17, 22,
9, 9, 13, 14, 13, 15, 23, 26,
11, 11, 14, 14, 15, 20, 26, 33,
14, 14, 13, 15, 20, 24, 33, 39,
17, 13, 15, 20, 24, 32, 39, 39,
19, 17, 23, 26, 33, 39, 39, 39,
24, 22, 26, 33, 39, 39, 39, 39
},
{/* level 2 */
13, 11, 13, 16, 20, 20, 29, 37,
11, 14, 14, 14, 16, 20, 26, 32,
13, 14, 15, 17, 20, 23, 35, 40,
16, 14, 17, 21, 23, 30, 40, 50,
20, 16, 20, 23, 30, 37, 50, 59,
20, 20, 23, 30, 37, 48, 59, 59,
29, 26, 35, 40, 50, 59, 59, 59,
37, 32, 40, 50, 59, 59, 59, 59
},
{/* level 3 */
17, 15, 17, 21, 20, 26, 38, 48,
15, 19, 18, 17, 20, 26, 35, 43,
17, 18, 20, 22, 26, 30, 46, 53,
21, 17, 22, 28, 30, 39, 53, 64,
20, 20, 26, 30, 39, 48, 64, 64,
26, 26, 30, 39, 48, 63, 64, 64,
38, 35, 46, 53, 64, 64, 64, 64,
48, 43, 53, 64, 64, 64, 64, 64
},
{/*level 4 - low quality */
21, 25, 32, 38, 54, 68, 68, 68,
25, 28, 24, 38, 54, 68, 68, 68,
32, 24, 32, 43, 66, 68, 68, 68,
38, 38, 43, 53, 68, 68, 68, 68,
54, 54, 66, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68
}
};
static const unsigned char hdctbl0[16] = {
0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
};
static const unsigned char hdctblg0[12] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb
};
static const unsigned char hactbl0[16] = {
0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
};
static const unsigned char hactblg0[162] = {
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa
};
static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
{
return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler);
}
static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
{
return container_of(fh, struct s5p_jpeg_ctx, fh);
}
static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl,
unsigned long tab, int len)
{
int i;
for (i = 0; i < len; i++)
writel((unsigned int)qtbl[i], regs + tab + (i * 0x04));
}
static inline void jpeg_set_qtbl_lum(void __iomem *regs, int quality)
{
/* this driver fills quantisation table 0 with data for luma */
jpeg_set_qtbl(regs, qtbl_luminance[quality], S5P_JPG_QTBL_CONTENT(0),
ARRAY_SIZE(qtbl_luminance[quality]));
}
static inline void jpeg_set_qtbl_chr(void __iomem *regs, int quality)
{
/* this driver fills quantisation table 1 with data for chroma */
jpeg_set_qtbl(regs, qtbl_chrominance[quality], S5P_JPG_QTBL_CONTENT(1),
ARRAY_SIZE(qtbl_chrominance[quality]));
}
static inline void jpeg_set_htbl(void __iomem *regs, const unsigned char *htbl,
unsigned long tab, int len)
{
int i;
for (i = 0; i < len; i++)
writel((unsigned int)htbl[i], regs + tab + (i * 0x04));
}
static inline void jpeg_set_hdctbl(void __iomem *regs)
{
/* this driver fills table 0 for this component */
jpeg_set_htbl(regs, hdctbl0, S5P_JPG_HDCTBL(0), ARRAY_SIZE(hdctbl0));
}
static inline void jpeg_set_hdctblg(void __iomem *regs)
{
/* this driver fills table 0 for this component */
jpeg_set_htbl(regs, hdctblg0, S5P_JPG_HDCTBLG(0), ARRAY_SIZE(hdctblg0));
}
static inline void jpeg_set_hactbl(void __iomem *regs)
{
/* this driver fills table 0 for this component */
jpeg_set_htbl(regs, hactbl0, S5P_JPG_HACTBL(0), ARRAY_SIZE(hactbl0));
}
static inline void jpeg_set_hactblg(void __iomem *regs)
{
/* this driver fills table 0 for this component */
jpeg_set_htbl(regs, hactblg0, S5P_JPG_HACTBLG(0), ARRAY_SIZE(hactblg0));
}
/*
* ============================================================================
* Device file operations
* ============================================================================
*/
static int queue_init(void *priv, struct vb2_queue *src_vq,
struct vb2_queue *dst_vq);
static struct s5p_jpeg_fmt *s5p_jpeg_find_format(unsigned int mode,
__u32 pixelformat);
static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx);
static int s5p_jpeg_open(struct file *file)
{
struct s5p_jpeg *jpeg = video_drvdata(file);
struct video_device *vfd = video_devdata(file);
struct s5p_jpeg_ctx *ctx;
struct s5p_jpeg_fmt *out_fmt;
int ret = 0;
ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
v4l2_fh_init(&ctx->fh, vfd);
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
file->private_data = &ctx->fh;
v4l2_fh_add(&ctx->fh);
ctx->jpeg = jpeg;
if (vfd == jpeg->vfd_encoder) {
ctx->mode = S5P_JPEG_ENCODE;
out_fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_RGB565);
} else {
ctx->mode = S5P_JPEG_DECODE;
out_fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_JPEG);
}
ret = s5p_jpeg_controls_create(ctx);
if (ret < 0)
goto error;
ctx->m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx, queue_init);
if (IS_ERR(ctx->m2m_ctx)) {
ret = PTR_ERR(ctx->m2m_ctx);
goto error;
}
ctx->out_q.fmt = out_fmt;
ctx->cap_q.fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_YUYV);
return 0;
error:
v4l2_fh_del(&ctx->fh);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
return ret;
}
static int s5p_jpeg_release(struct file *file)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
v4l2_m2m_ctx_release(ctx->m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
v4l2_fh_del(&ctx->fh);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
return 0;
}
static unsigned int s5p_jpeg_poll(struct file *file,
struct poll_table_struct *wait)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
return v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
}
static int s5p_jpeg_mmap(struct file *file, struct vm_area_struct *vma)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
}
static const struct v4l2_file_operations s5p_jpeg_fops = {
.owner = THIS_MODULE,
.open = s5p_jpeg_open,
.release = s5p_jpeg_release,
.poll = s5p_jpeg_poll,
.unlocked_ioctl = video_ioctl2,
.mmap = s5p_jpeg_mmap,
};
/*
* ============================================================================
* video ioctl operations
* ============================================================================
*/
static int get_byte(struct s5p_jpeg_buffer *buf)
{
if (buf->curr >= buf->size)
return -1;
return ((unsigned char *)buf->data)[buf->curr++];
}
static int get_word_be(struct s5p_jpeg_buffer *buf, unsigned int *word)
{
unsigned int temp;
int byte;
byte = get_byte(buf);
if (byte == -1)
return -1;
temp = byte << 8;
byte = get_byte(buf);
if (byte == -1)
return -1;
*word = (unsigned int)byte | temp;
return 0;
}
static void skip(struct s5p_jpeg_buffer *buf, long len)
{
if (len <= 0)
return;
while (len--)
get_byte(buf);
}
static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
unsigned long buffer, unsigned long size)
{
int c, components, notfound;
unsigned int height, width, word;
long length;
struct s5p_jpeg_buffer jpeg_buffer;
jpeg_buffer.size = size;
jpeg_buffer.data = buffer;
jpeg_buffer.curr = 0;
notfound = 1;
while (notfound) {
c = get_byte(&jpeg_buffer);
if (c == -1)
break;
if (c != 0xff)
continue;
do
c = get_byte(&jpeg_buffer);
while (c == 0xff);
if (c == -1)
break;
if (c == 0)
continue;
length = 0;
switch (c) {
/* SOF0: baseline JPEG */
case SOF0:
if (get_word_be(&jpeg_buffer, &word))
break;
if (get_byte(&jpeg_buffer) == -1)
break;
if (get_word_be(&jpeg_buffer, &height))
break;
if (get_word_be(&jpeg_buffer, &width))
break;
components = get_byte(&jpeg_buffer);
if (components == -1)
break;
notfound = 0;
skip(&jpeg_buffer, components * 3);
break;
/* skip payload-less markers */
case RST ... RST + 7:
case SOI:
case EOI:
case TEM:
break;
/* skip uninteresting payload markers */
default:
if (get_word_be(&jpeg_buffer, &word))
break;
length = (long)word - 2;
skip(&jpeg_buffer, length);
break;
}
}
result->w = width;
result->h = height;
result->size = components;
return !notfound;
}
static int s5p_jpeg_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
if (ctx->mode == S5P_JPEG_ENCODE) {
strlcpy(cap->driver, S5P_JPEG_M2M_NAME " encoder",
sizeof(cap->driver));
strlcpy(cap->card, S5P_JPEG_M2M_NAME " encoder",
sizeof(cap->card));
} else {
strlcpy(cap->driver, S5P_JPEG_M2M_NAME " decoder",
sizeof(cap->driver));
strlcpy(cap->card, S5P_JPEG_M2M_NAME " decoder",
sizeof(cap->card));
}
cap->bus_info[0] = 0;
cap->capabilities = V4L2_CAP_STREAMING |
V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_VIDEO_OUTPUT;
return 0;
}
static int enum_fmt(struct s5p_jpeg_fmt *formats, int n,
struct v4l2_fmtdesc *f, u32 type)
{
int i, num = 0;
for (i = 0; i < n; ++i) {
if (formats[i].types & type) {
/* index-th format of type type found ? */
if (num == f->index)
break;
/* Correct type but haven't reached our index yet,
* just increment per-type index */
++num;
}
}
/* Format not found */
if (i >= n)
return -EINVAL;
strlcpy(f->description, formats[i].name, sizeof(f->description));
f->pixelformat = formats[i].fourcc;
return 0;
}
static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
if (ctx->mode == S5P_JPEG_ENCODE)
return enum_fmt(formats_enc, NUM_FORMATS_ENC, f,
MEM2MEM_CAPTURE);
return enum_fmt(formats_dec, NUM_FORMATS_DEC, f, MEM2MEM_CAPTURE);
}
static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
if (ctx->mode == S5P_JPEG_ENCODE)
return enum_fmt(formats_enc, NUM_FORMATS_ENC, f,
MEM2MEM_OUTPUT);
return enum_fmt(formats_dec, NUM_FORMATS_DEC, f, MEM2MEM_OUTPUT);
}
static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx,
enum v4l2_buf_type type)
{
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
return &ctx->out_q;
if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
return &ctx->cap_q;
return NULL;
}
static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct vb2_queue *vq;
struct s5p_jpeg_q_data *q_data = NULL;
struct v4l2_pix_format *pix = &f->fmt.pix;
struct s5p_jpeg_ctx *ct = fh_to_ctx(priv);
vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type);
if (!vq)
return -EINVAL;
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE &&
ct->mode == S5P_JPEG_DECODE && !ct->hdr_parsed)
return -EINVAL;
q_data = get_q_data(ct, f->type);
BUG_ON(q_data == NULL);
pix->width = q_data->w;
pix->height = q_data->h;
pix->field = V4L2_FIELD_NONE;
pix->pixelformat = q_data->fmt->fourcc;
pix->bytesperline = 0;
if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) {
u32 bpl = q_data->w;
if (q_data->fmt->colplanes == 1)
bpl = (bpl * q_data->fmt->depth) >> 3;
pix->bytesperline = bpl;
}
pix->sizeimage = q_data->size;
return 0;
}
static struct s5p_jpeg_fmt *s5p_jpeg_find_format(unsigned int mode,
u32 pixelformat)
{
unsigned int k;
struct s5p_jpeg_fmt *formats;
int n;
if (mode == S5P_JPEG_ENCODE) {
formats = formats_enc;
n = NUM_FORMATS_ENC;
} else {
formats = formats_dec;
n = NUM_FORMATS_DEC;
}
for (k = 0; k < n; k++) {
struct s5p_jpeg_fmt *fmt = &formats[k];
if (fmt->fourcc == pixelformat)
return fmt;
}
return NULL;
}
static void jpeg_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax,
unsigned int walign,
u32 *h, unsigned int hmin, unsigned int hmax,
unsigned int halign)
{
int width, height, w_step, h_step;
width = *w;
height = *h;
w_step = 1 << walign;
h_step = 1 << halign;
v4l_bound_align_image(w, wmin, wmax, walign, h, hmin, hmax, halign, 0);
if (*w < width && (*w + w_step) < wmax)
*w += w_step;
if (*h < height && (*h + h_step) < hmax)
*h += h_step;
}
static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt,
struct s5p_jpeg_ctx *ctx, int q_type)
{
struct v4l2_pix_format *pix = &f->fmt.pix;
if (pix->field == V4L2_FIELD_ANY)
pix->field = V4L2_FIELD_NONE;
else if (pix->field != V4L2_FIELD_NONE)
return -EINVAL;
/* V4L2 specification suggests the driver corrects the format struct
* if any of the dimensions is unsupported */
if (q_type == MEM2MEM_OUTPUT)
jpeg_bound_align_image(&pix->width, S5P_JPEG_MIN_WIDTH,
S5P_JPEG_MAX_WIDTH, 0,
&pix->height, S5P_JPEG_MIN_HEIGHT,
S5P_JPEG_MAX_HEIGHT, 0);
else
jpeg_bound_align_image(&pix->width, S5P_JPEG_MIN_WIDTH,
S5P_JPEG_MAX_WIDTH, fmt->h_align,
&pix->height, S5P_JPEG_MIN_HEIGHT,
S5P_JPEG_MAX_HEIGHT, fmt->v_align);
if (fmt->fourcc == V4L2_PIX_FMT_JPEG) {
if (pix->sizeimage <= 0)
pix->sizeimage = PAGE_SIZE;
pix->bytesperline = 0;
} else {
u32 bpl = pix->bytesperline;
if (fmt->colplanes > 1 && bpl < pix->width)
bpl = pix->width; /* planar */
if (fmt->colplanes == 1 && /* packed */
(bpl << 3) * fmt->depth < pix->width)
bpl = (pix->width * fmt->depth) >> 3;
pix->bytesperline = bpl;
pix->sizeimage = (pix->width * pix->height * fmt->depth) >> 3;
}
return 0;
}
static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
struct s5p_jpeg_fmt *fmt;
fmt = s5p_jpeg_find_format(ctx->mode, f->fmt.pix.pixelformat);
if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) {
v4l2_err(&ctx->jpeg->v4l2_dev,
"Fourcc format (0x%08x) invalid.\n",
f->fmt.pix.pixelformat);
return -EINVAL;
}
return vidioc_try_fmt(f, fmt, ctx, MEM2MEM_CAPTURE);
}
static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
struct s5p_jpeg_fmt *fmt;
fmt = s5p_jpeg_find_format(ctx->mode, f->fmt.pix.pixelformat);
if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) {
v4l2_err(&ctx->jpeg->v4l2_dev,
"Fourcc format (0x%08x) invalid.\n",
f->fmt.pix.pixelformat);
return -EINVAL;
}
return vidioc_try_fmt(f, fmt, ctx, MEM2MEM_OUTPUT);
}
static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
{
struct vb2_queue *vq;
struct s5p_jpeg_q_data *q_data = NULL;
struct v4l2_pix_format *pix = &f->fmt.pix;
vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type);
if (!vq)
return -EINVAL;
q_data = get_q_data(ct, f->type);
BUG_ON(q_data == NULL);
if (vb2_is_busy(vq)) {
v4l2_err(&ct->jpeg->v4l2_dev, "%s queue busy\n", __func__);
return -EBUSY;
}
q_data->fmt = s5p_jpeg_find_format(ct->mode, pix->pixelformat);
q_data->w = pix->width;
q_data->h = pix->height;
if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG)
q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3;
else
q_data->size = pix->sizeimage;
return 0;
}
static int s5p_jpeg_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
int ret;
ret = s5p_jpeg_try_fmt_vid_cap(file, priv, f);
if (ret)
return ret;
return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
}
static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
int ret;
ret = s5p_jpeg_try_fmt_vid_out(file, priv, f);
if (ret)
return ret;
return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
}
static int s5p_jpeg_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *reqbufs)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
}
static int s5p_jpeg_querybuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
}
static int s5p_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
}
static int s5p_jpeg_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
}
static int s5p_jpeg_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
}
static int s5p_jpeg_streamoff(struct file *file, void *priv,
enum v4l2_buf_type type)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
}
int s5p_jpeg_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
/* For JPEG blob active == default == bounds */
switch (s->target) {
case V4L2_SEL_TGT_CROP_ACTIVE:
case V4L2_SEL_TGT_CROP_BOUNDS:
case V4L2_SEL_TGT_CROP_DEFAULT:
case V4L2_SEL_TGT_COMPOSE_ACTIVE:
case V4L2_SEL_TGT_COMPOSE_DEFAULT:
s->r.width = ctx->out_q.w;
s->r.height = ctx->out_q.h;
break;
case V4L2_SEL_TGT_COMPOSE_BOUNDS:
case V4L2_SEL_TGT_COMPOSE_PADDED:
s->r.width = ctx->cap_q.w;
s->r.height = ctx->cap_q.h;
break;
default:
return -EINVAL;
}
s->r.left = 0;
s->r.top = 0;
return 0;
}
/*
* V4L2 controls
*/
static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{
struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl);
struct s5p_jpeg *jpeg = ctx->jpeg;
unsigned long flags;
switch (ctrl->id) {
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
spin_lock_irqsave(&jpeg->slock, flags);
WARN_ON(ctx->subsampling > S5P_SUBSAMPLING_MODE_GRAY);
if (ctx->subsampling > 2)
ctrl->val = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
else
ctrl->val = ctx->subsampling;
spin_unlock_irqrestore(&jpeg->slock, flags);
break;
}
return 0;
}
static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl);
unsigned long flags;
spin_lock_irqsave(&ctx->jpeg->slock, flags);
switch (ctrl->id) {
case V4L2_CID_JPEG_COMPRESSION_QUALITY:
ctx->compr_quality = S5P_JPEG_COMPR_QUAL_WORST - ctrl->val;
break;
case V4L2_CID_JPEG_RESTART_INTERVAL:
ctx->restart_interval = ctrl->val;
break;
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
ctx->subsampling = ctrl->val;
break;
}
spin_unlock_irqrestore(&ctx->jpeg->slock, flags);
return 0;
}
static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops = {
.g_volatile_ctrl = s5p_jpeg_g_volatile_ctrl,
.s_ctrl = s5p_jpeg_s_ctrl,
};
static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx)
{
unsigned int mask = ~0x27; /* 444, 422, 420, GRAY */
struct v4l2_ctrl *ctrl;
v4l2_ctrl_handler_init(&ctx->ctrl_handler, 3);
if (ctx->mode == S5P_JPEG_ENCODE) {
v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,
V4L2_CID_JPEG_COMPRESSION_QUALITY,
0, 3, 1, 3);
v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,
V4L2_CID_JPEG_RESTART_INTERVAL,
0, 3, 0xffff, 0);
mask = ~0x06; /* 422, 420 */
}
ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,
V4L2_CID_JPEG_CHROMA_SUBSAMPLING,
V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY, mask,
V4L2_JPEG_CHROMA_SUBSAMPLING_422);
if (ctx->ctrl_handler.error)
return ctx->ctrl_handler.error;
if (ctx->mode == S5P_JPEG_DECODE)
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE |
V4L2_CTRL_FLAG_READ_ONLY;
return 0;
}
static const struct v4l2_ioctl_ops s5p_jpeg_ioctl_ops = {
.vidioc_querycap = s5p_jpeg_querycap,
.vidioc_enum_fmt_vid_cap = s5p_jpeg_enum_fmt_vid_cap,
.vidioc_enum_fmt_vid_out = s5p_jpeg_enum_fmt_vid_out,
.vidioc_g_fmt_vid_cap = s5p_jpeg_g_fmt,
.vidioc_g_fmt_vid_out = s5p_jpeg_g_fmt,
.vidioc_try_fmt_vid_cap = s5p_jpeg_try_fmt_vid_cap,
.vidioc_try_fmt_vid_out = s5p_jpeg_try_fmt_vid_out,
.vidioc_s_fmt_vid_cap = s5p_jpeg_s_fmt_vid_cap,
.vidioc_s_fmt_vid_out = s5p_jpeg_s_fmt_vid_out,
.vidioc_reqbufs = s5p_jpeg_reqbufs,
.vidioc_querybuf = s5p_jpeg_querybuf,
.vidioc_qbuf = s5p_jpeg_qbuf,
.vidioc_dqbuf = s5p_jpeg_dqbuf,
.vidioc_streamon = s5p_jpeg_streamon,
.vidioc_streamoff = s5p_jpeg_streamoff,
.vidioc_g_selection = s5p_jpeg_g_selection,
};
/*
* ============================================================================
* mem2mem callbacks
* ============================================================================
*/
static void s5p_jpeg_device_run(void *priv)
{
struct s5p_jpeg_ctx *ctx = priv;
struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *src_buf, *dst_buf;
unsigned long src_addr, dst_addr;
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
src_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
dst_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
jpeg_reset(jpeg->regs);
jpeg_poweron(jpeg->regs);
jpeg_proc_mode(jpeg->regs, ctx->mode);
if (ctx->mode == S5P_JPEG_ENCODE) {
if (ctx->out_q.fmt->fourcc == V4L2_PIX_FMT_RGB565)
jpeg_input_raw_mode(jpeg->regs, S5P_JPEG_RAW_IN_565);
else
jpeg_input_raw_mode(jpeg->regs, S5P_JPEG_RAW_IN_422);
jpeg_subsampling_mode(jpeg->regs, ctx->subsampling);
jpeg_dri(jpeg->regs, ctx->restart_interval);
jpeg_x(jpeg->regs, ctx->out_q.w);
jpeg_y(jpeg->regs, ctx->out_q.h);
jpeg_imgadr(jpeg->regs, src_addr);
jpeg_jpgadr(jpeg->regs, dst_addr);
/* ultimately comes from sizeimage from userspace */
jpeg_enc_stream_int(jpeg->regs, ctx->cap_q.size);
/* JPEG RGB to YCbCr conversion matrix */
jpeg_coef(jpeg->regs, 1, 1, S5P_JPEG_COEF11);
jpeg_coef(jpeg->regs, 1, 2, S5P_JPEG_COEF12);
jpeg_coef(jpeg->regs, 1, 3, S5P_JPEG_COEF13);
jpeg_coef(jpeg->regs, 2, 1, S5P_JPEG_COEF21);
jpeg_coef(jpeg->regs, 2, 2, S5P_JPEG_COEF22);
jpeg_coef(jpeg->regs, 2, 3, S5P_JPEG_COEF23);
jpeg_coef(jpeg->regs, 3, 1, S5P_JPEG_COEF31);
jpeg_coef(jpeg->regs, 3, 2, S5P_JPEG_COEF32);
jpeg_coef(jpeg->regs, 3, 3, S5P_JPEG_COEF33);
/*
* JPEG IP allows storing 4 quantization tables
* We fill table 0 for luma and table 1 for chroma
*/
jpeg_set_qtbl_lum(jpeg->regs, ctx->compr_quality);
jpeg_set_qtbl_chr(jpeg->regs, ctx->compr_quality);
/* use table 0 for Y */
jpeg_qtbl(jpeg->regs, 1, 0);
/* use table 1 for Cb and Cr*/
jpeg_qtbl(jpeg->regs, 2, 1);
jpeg_qtbl(jpeg->regs, 3, 1);
/* Y, Cb, Cr use Huffman table 0 */
jpeg_htbl_ac(jpeg->regs, 1);
jpeg_htbl_dc(jpeg->regs, 1);
jpeg_htbl_ac(jpeg->regs, 2);
jpeg_htbl_dc(jpeg->regs, 2);
jpeg_htbl_ac(jpeg->regs, 3);
jpeg_htbl_dc(jpeg->regs, 3);
} else { /* S5P_JPEG_DECODE */
jpeg_rst_int_enable(jpeg->regs, true);
jpeg_data_num_int_enable(jpeg->regs, true);
jpeg_final_mcu_num_int_enable(jpeg->regs, true);
if (ctx->cap_q.fmt->fourcc == V4L2_PIX_FMT_YUYV)
jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_422);
else
jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_420);
jpeg_jpgadr(jpeg->regs, src_addr);
jpeg_imgadr(jpeg->regs, dst_addr);
}
jpeg_start(jpeg->regs);
}
static int s5p_jpeg_job_ready(void *priv)
{
struct s5p_jpeg_ctx *ctx = priv;
if (ctx->mode == S5P_JPEG_DECODE)
return ctx->hdr_parsed;
return 1;
}
static void s5p_jpeg_job_abort(void *priv)
{
}
static struct v4l2_m2m_ops s5p_jpeg_m2m_ops = {
.device_run = s5p_jpeg_device_run,
.job_ready = s5p_jpeg_job_ready,
.job_abort = s5p_jpeg_job_abort,
};
/*
* ============================================================================
* Queue operations
* ============================================================================
*/
static int s5p_jpeg_queue_setup(struct vb2_queue *vq,
const struct v4l2_format *fmt,
unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[])
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vq);
struct s5p_jpeg_q_data *q_data = NULL;
unsigned int size, count = *nbuffers;
q_data = get_q_data(ctx, vq->type);
BUG_ON(q_data == NULL);
size = q_data->size;
/*
* header is parsed during decoding and parsed information stored
* in the context so we do not allow another buffer to overwrite it
*/
if (ctx->mode == S5P_JPEG_DECODE)
count = 1;
*nbuffers = count;
*nplanes = 1;
sizes[0] = size;
alloc_ctxs[0] = ctx->jpeg->alloc_ctx;
return 0;
}
static int s5p_jpeg_buf_prepare(struct vb2_buffer *vb)
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
struct s5p_jpeg_q_data *q_data = NULL;
q_data = get_q_data(ctx, vb->vb2_queue->type);
BUG_ON(q_data == NULL);
if (vb2_plane_size(vb, 0) < q_data->size) {
pr_err("%s data will not fit into plane (%lu < %lu)\n",
__func__, vb2_plane_size(vb, 0),
(long)q_data->size);
return -EINVAL;
}
vb2_set_plane_payload(vb, 0, q_data->size);
return 0;
}
static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
if (ctx->mode == S5P_JPEG_DECODE &&
vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
struct s5p_jpeg_q_data tmp, *q_data;
ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp,
(unsigned long)vb2_plane_vaddr(vb, 0),
min((unsigned long)ctx->out_q.size,
vb2_get_plane_payload(vb, 0)));
if (!ctx->hdr_parsed) {
vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
return;
}
q_data = &ctx->out_q;
q_data->w = tmp.w;
q_data->h = tmp.h;
q_data = &ctx->cap_q;
q_data->w = tmp.w;
q_data->h = tmp.h;
jpeg_bound_align_image(&q_data->w, S5P_JPEG_MIN_WIDTH,
S5P_JPEG_MAX_WIDTH, q_data->fmt->h_align,
&q_data->h, S5P_JPEG_MIN_HEIGHT,
S5P_JPEG_MAX_HEIGHT, q_data->fmt->v_align
);
q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3;
}
if (ctx->m2m_ctx)
v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
}
static void s5p_jpeg_wait_prepare(struct vb2_queue *vq)
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vq);
mutex_unlock(&ctx->jpeg->lock);
}
static void s5p_jpeg_wait_finish(struct vb2_queue *vq)
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vq);
mutex_lock(&ctx->jpeg->lock);
}
static int s5p_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q);
int ret;
ret = pm_runtime_get_sync(ctx->jpeg->dev);
return ret > 0 ? 0 : ret;
}
static int s5p_jpeg_stop_streaming(struct vb2_queue *q)
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q);
pm_runtime_put(ctx->jpeg->dev);
return 0;
}
static struct vb2_ops s5p_jpeg_qops = {
.queue_setup = s5p_jpeg_queue_setup,
.buf_prepare = s5p_jpeg_buf_prepare,
.buf_queue = s5p_jpeg_buf_queue,
.wait_prepare = s5p_jpeg_wait_prepare,
.wait_finish = s5p_jpeg_wait_finish,
.start_streaming = s5p_jpeg_start_streaming,
.stop_streaming = s5p_jpeg_stop_streaming,
};
static int queue_init(void *priv, struct vb2_queue *src_vq,
struct vb2_queue *dst_vq)
{
struct s5p_jpeg_ctx *ctx = priv;
int ret;
memset(src_vq, 0, sizeof(*src_vq));
src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
src_vq->io_modes = VB2_MMAP | VB2_USERPTR;
src_vq->drv_priv = ctx;
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->ops = &s5p_jpeg_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
ret = vb2_queue_init(src_vq);
if (ret)
return ret;
memset(dst_vq, 0, sizeof(*dst_vq));
dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
dst_vq->io_modes = VB2_MMAP | VB2_USERPTR;
dst_vq->drv_priv = ctx;
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->ops = &s5p_jpeg_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
return vb2_queue_init(dst_vq);
}
/*
* ============================================================================
* ISR
* ============================================================================
*/
static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
{
struct s5p_jpeg *jpeg = dev_id;
struct s5p_jpeg_ctx *curr_ctx;
struct vb2_buffer *src_buf, *dst_buf;
unsigned long payload_size = 0;
enum vb2_buffer_state state = VB2_BUF_STATE_DONE;
bool enc_jpeg_too_large = false;
bool timer_elapsed = false;
bool op_completed = false;
spin_lock(&jpeg->slock);
curr_ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev);
src_buf = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
if (curr_ctx->mode == S5P_JPEG_ENCODE)
enc_jpeg_too_large = jpeg_enc_stream_stat(jpeg->regs);
timer_elapsed = jpeg_timer_stat(jpeg->regs);
op_completed = jpeg_result_stat_ok(jpeg->regs);
if (curr_ctx->mode == S5P_JPEG_DECODE)
op_completed = op_completed && jpeg_stream_stat_ok(jpeg->regs);
if (enc_jpeg_too_large) {
state = VB2_BUF_STATE_ERROR;
jpeg_clear_enc_stream_stat(jpeg->regs);
} else if (timer_elapsed) {
state = VB2_BUF_STATE_ERROR;
jpeg_clear_timer_stat(jpeg->regs);
} else if (!op_completed) {
state = VB2_BUF_STATE_ERROR;
} else {
payload_size = jpeg_compressed_size(jpeg->regs);
}
v4l2_m2m_buf_done(src_buf, state);
if (curr_ctx->mode == S5P_JPEG_ENCODE)
vb2_set_plane_payload(dst_buf, 0, payload_size);
v4l2_m2m_buf_done(dst_buf, state);
v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->m2m_ctx);
curr_ctx->subsampling = jpeg_get_subsampling_mode(jpeg->regs);
spin_unlock(&jpeg->slock);
jpeg_clear_int(jpeg->regs);
return IRQ_HANDLED;
}
/*
* ============================================================================
* Driver basic infrastructure
* ============================================================================
*/
static int s5p_jpeg_probe(struct platform_device *pdev)
{
struct s5p_jpeg *jpeg;
struct resource *res;
int ret;
/* JPEG IP abstraction struct */
jpeg = kzalloc(sizeof(struct s5p_jpeg), GFP_KERNEL);
if (!jpeg)
return -ENOMEM;
mutex_init(&jpeg->lock);
spin_lock_init(&jpeg->slock);
jpeg->dev = &pdev->dev;
/* memory-mapped registers */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "cannot find IO resource\n");
ret = -ENOENT;
goto jpeg_alloc_rollback;
}
jpeg->ioarea = request_mem_region(res->start, resource_size(res),
pdev->name);
if (!jpeg->ioarea) {
dev_err(&pdev->dev, "cannot request IO\n");
ret = -ENXIO;
goto jpeg_alloc_rollback;
}
jpeg->regs = ioremap(res->start, resource_size(res));
if (!jpeg->regs) {
dev_err(&pdev->dev, "cannot map IO\n");
ret = -ENXIO;
goto mem_region_rollback;
}
dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
jpeg->regs, jpeg->ioarea, res);
/* interrupt service routine registration */
jpeg->irq = ret = platform_get_irq(pdev, 0);
if (ret < 0) {
dev_err(&pdev->dev, "cannot find IRQ\n");
goto ioremap_rollback;
}
ret = request_irq(jpeg->irq, s5p_jpeg_irq, 0,
dev_name(&pdev->dev), jpeg);
if (ret) {
dev_err(&pdev->dev, "cannot claim IRQ %d\n", jpeg->irq);
goto ioremap_rollback;
}
/* clocks */
jpeg->clk = clk_get(&pdev->dev, "jpeg");
if (IS_ERR(jpeg->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
ret = PTR_ERR(jpeg->clk);
goto request_irq_rollback;
}
dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk);
clk_enable(jpeg->clk);
/* v4l2 device */
ret = v4l2_device_register(&pdev->dev, &jpeg->v4l2_dev);
if (ret) {
dev_err(&pdev->dev, "Failed to register v4l2 device\n");
goto clk_get_rollback;
}
/* mem2mem device */
jpeg->m2m_dev = v4l2_m2m_init(&s5p_jpeg_m2m_ops);
if (IS_ERR(jpeg->m2m_dev)) {
v4l2_err(&jpeg->v4l2_dev, "Failed to init mem2mem device\n");
ret = PTR_ERR(jpeg->m2m_dev);
goto device_register_rollback;
}
jpeg->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
if (IS_ERR(jpeg->alloc_ctx)) {
v4l2_err(&jpeg->v4l2_dev, "Failed to init memory allocator\n");
ret = PTR_ERR(jpeg->alloc_ctx);
goto m2m_init_rollback;
}
/* JPEG encoder /dev/videoX node */
jpeg->vfd_encoder = video_device_alloc();
if (!jpeg->vfd_encoder) {
v4l2_err(&jpeg->v4l2_dev, "Failed to allocate video device\n");
ret = -ENOMEM;
goto vb2_allocator_rollback;
}
strlcpy(jpeg->vfd_encoder->name, S5P_JPEG_M2M_NAME,
sizeof(jpeg->vfd_encoder->name));
jpeg->vfd_encoder->fops = &s5p_jpeg_fops;
jpeg->vfd_encoder->ioctl_ops = &s5p_jpeg_ioctl_ops;
jpeg->vfd_encoder->minor = -1;
jpeg->vfd_encoder->release = video_device_release;
jpeg->vfd_encoder->lock = &jpeg->lock;
jpeg->vfd_encoder->v4l2_dev = &jpeg->v4l2_dev;
/* Locking in file operations other than ioctl should be done
by the driver, not the V4L2 core.
This driver needs auditing so that this flag can be removed. */
set_bit(V4L2_FL_LOCK_ALL_FOPS, &jpeg->vfd_encoder->flags);
ret = video_register_device(jpeg->vfd_encoder, VFL_TYPE_GRABBER, -1);
if (ret) {
v4l2_err(&jpeg->v4l2_dev, "Failed to register video device\n");
goto enc_vdev_alloc_rollback;
}
video_set_drvdata(jpeg->vfd_encoder, jpeg);
v4l2_info(&jpeg->v4l2_dev,
"encoder device registered as /dev/video%d\n",
jpeg->vfd_encoder->num);
/* JPEG decoder /dev/videoX node */
jpeg->vfd_decoder = video_device_alloc();
if (!jpeg->vfd_decoder) {
v4l2_err(&jpeg->v4l2_dev, "Failed to allocate video device\n");
ret = -ENOMEM;
goto enc_vdev_register_rollback;
}
strlcpy(jpeg->vfd_decoder->name, S5P_JPEG_M2M_NAME,
sizeof(jpeg->vfd_decoder->name));
jpeg->vfd_decoder->fops = &s5p_jpeg_fops;
jpeg->vfd_decoder->ioctl_ops = &s5p_jpeg_ioctl_ops;
jpeg->vfd_decoder->minor = -1;
jpeg->vfd_decoder->release = video_device_release;
jpeg->vfd_decoder->lock = &jpeg->lock;
jpeg->vfd_decoder->v4l2_dev = &jpeg->v4l2_dev;
/* Locking in file operations other than ioctl should be done by the driver,
not the V4L2 core.
This driver needs auditing so that this flag can be removed. */
set_bit(V4L2_FL_LOCK_ALL_FOPS, &jpeg->vfd_decoder->flags);
ret = video_register_device(jpeg->vfd_decoder, VFL_TYPE_GRABBER, -1);
if (ret) {
v4l2_err(&jpeg->v4l2_dev, "Failed to register video device\n");
goto dec_vdev_alloc_rollback;
}
video_set_drvdata(jpeg->vfd_decoder, jpeg);
v4l2_info(&jpeg->v4l2_dev,
"decoder device registered as /dev/video%d\n",
jpeg->vfd_decoder->num);
/* final statements & power management */
platform_set_drvdata(pdev, jpeg);
pm_runtime_enable(&pdev->dev);
v4l2_info(&jpeg->v4l2_dev, "Samsung S5P JPEG codec\n");
return 0;
dec_vdev_alloc_rollback:
video_device_release(jpeg->vfd_decoder);
enc_vdev_register_rollback:
video_unregister_device(jpeg->vfd_encoder);
enc_vdev_alloc_rollback:
video_device_release(jpeg->vfd_encoder);
vb2_allocator_rollback:
vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx);
m2m_init_rollback:
v4l2_m2m_release(jpeg->m2m_dev);
device_register_rollback:
v4l2_device_unregister(&jpeg->v4l2_dev);
clk_get_rollback:
clk_disable(jpeg->clk);
clk_put(jpeg->clk);
request_irq_rollback:
free_irq(jpeg->irq, jpeg);
ioremap_rollback:
iounmap(jpeg->regs);
mem_region_rollback:
release_resource(jpeg->ioarea);
release_mem_region(jpeg->ioarea->start, resource_size(jpeg->ioarea));
jpeg_alloc_rollback:
kfree(jpeg);
return ret;
}
static int s5p_jpeg_remove(struct platform_device *pdev)
{
struct s5p_jpeg *jpeg = platform_get_drvdata(pdev);
pm_runtime_disable(jpeg->dev);
video_unregister_device(jpeg->vfd_decoder);
video_device_release(jpeg->vfd_decoder);
video_unregister_device(jpeg->vfd_encoder);
video_device_release(jpeg->vfd_encoder);
vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx);
v4l2_m2m_release(jpeg->m2m_dev);
v4l2_device_unregister(&jpeg->v4l2_dev);
clk_disable(jpeg->clk);
clk_put(jpeg->clk);
free_irq(jpeg->irq, jpeg);
iounmap(jpeg->regs);
release_resource(jpeg->ioarea);
release_mem_region(jpeg->ioarea->start, resource_size(jpeg->ioarea));
kfree(jpeg);
return 0;
}
static int s5p_jpeg_runtime_suspend(struct device *dev)
{
return 0;
}
static int s5p_jpeg_runtime_resume(struct device *dev)
{
struct s5p_jpeg *jpeg = dev_get_drvdata(dev);
/*
* JPEG IP allows storing two Huffman tables for each component
* We fill table 0 for each component
*/
jpeg_set_hdctbl(jpeg->regs);
jpeg_set_hdctblg(jpeg->regs);
jpeg_set_hactbl(jpeg->regs);
jpeg_set_hactblg(jpeg->regs);
return 0;
}
static const struct dev_pm_ops s5p_jpeg_pm_ops = {
.runtime_suspend = s5p_jpeg_runtime_suspend,
.runtime_resume = s5p_jpeg_runtime_resume,
};
static struct platform_driver s5p_jpeg_driver = {
.probe = s5p_jpeg_probe,
.remove = s5p_jpeg_remove,
.driver = {
.owner = THIS_MODULE,
.name = S5P_JPEG_M2M_NAME,
.pm = &s5p_jpeg_pm_ops,
},
};
static int __init
s5p_jpeg_register(void)
{
int ret;
pr_info("S5P JPEG V4L2 Driver, (c) 2011 Samsung Electronics\n");
ret = platform_driver_register(&s5p_jpeg_driver);
if (ret)
pr_err("%s: failed to register jpeg driver\n", __func__);
return ret;
}
static void __exit
s5p_jpeg_unregister(void)
{
platform_driver_unregister(&s5p_jpeg_driver);
}
module_init(s5p_jpeg_register);
module_exit(s5p_jpeg_unregister);
MODULE_AUTHOR("Andrzej Pietrasiewicz <[email protected]>");
MODULE_DESCRIPTION("Samsung JPEG codec driver");
MODULE_LICENSE("GPL");
|
ArthySundaram/chromeos-kvm
|
drivers/media/video/s5p-jpeg/jpeg-core.c
|
C
|
gpl-2.0
| 40,954 |
<?php
/**
*
* Board Announcements extension for the phpBB Forum Software package.
*
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
//
// Some characters you may want to copy&paste:
// ’ » “ ” …
//
$lang = array_merge($lang, array(
// ACP Module
'ACP_BOARD_ANNOUNCEMENTS' => 'Annunci',
'ACP_BOARD_ANNOUNCEMENTS_SETTINGS' => 'Impostazioni annuncio',
// ACP Logs
'BOARD_ANNOUNCEMENTS_UPDATED_LOG' => '<strong>Impostazioni annuncio modificate</strong>',
));
|
phpbb-extensions/boardannouncements
|
language/it/info_acp_board_announcements.php
|
PHP
|
gpl-2.0
| 1,287 |
package com.redhat.ceylon.compiler.java.codegen;
import com.redhat.ceylon.compiler.java.codegen.Naming.Prefix;
import com.redhat.ceylon.compiler.typechecker.model.Functional;
import com.redhat.ceylon.compiler.typechecker.model.Parameter;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.util.ListBuffer;
/**
* An argument to an annotation class instantiation that is a parameter
* of the annotation constructor.
*/
public class ParameterAnnotationTerm extends AnnotationTerm implements AnnotationFieldName {
private Parameter sourceParameter;
private boolean spread;
/**
* The annotation constructor parameter
*/
public Parameter getSourceParameter() {
return sourceParameter;
}
public void setSourceParameter(Parameter sourceParameter) {
this.sourceParameter = sourceParameter;
}
/**
* Whether the argument is spread
*/
public boolean isSpread() {
return spread;
}
public void setSpread(boolean spread) {
this.spread = spread;
}
public String toString() {
return (isSpread() ? "*" : "") + getSourceParameter().getName();
}
@Override
public String getFieldName() {
return sourceParameter.getName();
}
@Override
public Prefix getFieldNamePrefix() {
return Prefix.$default$;
}
@Override
public Parameter getAnnotationField() {
return getSourceParameter();
}
@Override
public int encode(AbstractTransformer gen, ListBuffer<JCExpression> instantiations) {
Parameter parameter = getSourceParameter();
int index = ((Functional)parameter.getDeclaration()).getParameterLists().get(0).getParameters().indexOf(parameter);
if (isSpread()) {
index += 256;
}
return index;
}
@Override
public JCExpression makeAnnotationArgumentValue(
ExpressionTransformer exprGen, AnnotationInvocation ai,
com.sun.tools.javac.util.List<AnnotationFieldName> fieldPath) {
// The value of the argument is the value of the caller's argument
// TODO WTF is going on here? surely this first loop should return, or do *something*?
AnnotationTerm defaultArgument = null;
for (AnnotationArgument aa : ai.getAnnotationArguments()) {
if (aa.getParameter().equals(this.getSourceParameter())) {
aa.getTerm().makeAnnotationArgumentValue(exprGen, ai, fieldPath);
}
}
if (ai.getConstructorParameters() != null) {
for (AnnotationConstructorParameter p : ai.getConstructorParameters()) {
if (p.getParameter().equals(getSourceParameter())) {
defaultArgument = p.getDefaultArgument();
if (defaultArgument != null) {
return defaultArgument.makeAnnotationArgumentValue(exprGen, ai, com.sun.tools.javac.util.List.<AnnotationFieldName>of(this));
} else if (Strategy.hasEmptyDefaultArgument(p.getParameter())) {
return exprGen.make().NewArray(null, null, com.sun.tools.javac.util.List.<JCExpression>nil());
}
}
}
}
return exprGen.makeErroneous(null, "compiler bug: not implemented yet");
}
@Override
public com.sun.tools.javac.util.List<JCAnnotation> makeDpmAnnotations(
ExpressionTransformer exprGen) {
// TODO I suppose we can have a constructor like (X x, X y=x) so we do need to support this.
// Or even (X x1, X x2, X[] x3=[x1, x2])
return exprGen.makeAtParameterValue(makeLiteral(exprGen));
}
public JCExpression makeLiteral(ExpressionTransformer exprGen) {
return exprGen.make().Literal(getSourceParameter().getName());
}
@Override
public com.sun.tools.javac.util.List<JCAnnotation> makeExprs(
ExpressionTransformer exprGen,
com.sun.tools.javac.util.List<JCAnnotation> value) {
// TODO Auto-generated method stub
return null;
}
@Override
public com.sun.tools.javac.util.List<JCAnnotation> makeExprAnnotations(
ExpressionTransformer exprGen, AnnotationInvocation toplevel,
com.sun.tools.javac.util.List<AnnotationFieldName> fieldPath) {
// TODO Auto-generated method stub
return null;
}
}
|
jvasileff/ceylon-compiler
|
src/com/redhat/ceylon/compiler/java/codegen/ParameterAnnotationTerm.java
|
Java
|
gpl-2.0
| 4,506 |
/*
* Copyright (c) 2013. Intel Corporation. All rights reserved.
* Copyright (c) 2006-2012. QLogic Corporation. All rights reserved.
* Copyright (c) 2003-2006, PathScale, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "psm_user.h"
#include "psm_am.h"
#include "psm_am_internal.h"
#include "ips_proto.h"
#include "ips_proto_internal.h"
#define IPS_AMFLAG_ISTINY 1
struct ips_am_token {
struct psmi_am_token tok;
/* ptl-specific token stuff */
struct ips_proto_am *proto_am;
};
psm_error_t
ips_proto_am_init(struct ips_proto *proto,
int num_of_send_bufs, int num_of_send_desc,
uint32_t imm_size, struct ips_proto_am *proto_am)
{
psm_error_t err = PSM_OK;
int send_buf_size = proto->scb_bufsize;
proto_am->proto = proto;
proto_am->scbc_request = &proto->scbc_egr;
if ((err = ips_scbctrl_init(&proto->ep->context, num_of_send_desc,
num_of_send_bufs, imm_size, send_buf_size,
NULL, NULL, &proto_am->scbc_reply)))
goto fail;
fail:
return err;
}
psm_error_t
ips_proto_am_fini(struct ips_proto_am *proto_am)
{
return PSM_OK;
}
static
psm_error_t
am_short_reqrep(struct ips_proto_am *proto_am, ips_scb_t *scb,
struct ptl_epaddr *ipsaddr,
psm_amarg_t *args, int nargs, uint8_t sub_opcode,
void *src, size_t len, int flags, int pad_bytes)
{
int i, hdr_qwords = PSM_AM_HDR_QWORDS;
ptl_epaddr_flow_t flowid = ((sub_opcode == OPCODE_AM_REQUEST) ||
(sub_opcode == OPCODE_AM_REQUEST_NOREPLY)) ?
EP_FLOW_GO_BACK_N_AM_REQ : EP_FLOW_GO_BACK_N_AM_RSP;
struct ips_flow *flow = &ipsaddr->flows[flowid];
_IPATH_VDBG("%s src=%p len=%d, nargs=%d\n",
((sub_opcode == OPCODE_AM_REQUEST) ||
(sub_opcode == OPCODE_AM_REQUEST_NOREPLY)) ? "req" : "rep",
src, (int) len, nargs);
if (nargs == 1) { /* fastpath */
scb->ips_lrh.data[0].u64w0 = args[0].u64w0;
hdr_qwords--;
}
else if (nargs > 1) {
/* Easily unrollable but leave as is in case we can increase qwords
* on the chip in the near future */
for (i = 0; i < PSM_AM_HDR_QWORDS; i++, hdr_qwords--)
scb->ips_lrh.data[i].u64w0 = args[i].u64w0;
if (nargs > PSM_AM_HDR_QWORDS) {
/* Slow case -- we don't have iovec and not enough space in the
* message header, so we have to copy the user's arguments even if
* the payload is marked ASYNC */
uintptr_t bufp = (uintptr_t) scb->payload;
psmi_mq_mtucpy((void *) bufp, &args[PSM_AM_HDR_QWORDS],
sizeof(psm_amarg_t) * (nargs - PSM_AM_HDR_QWORDS));
bufp += sizeof(psm_amarg_t) * (nargs - PSM_AM_HDR_QWORDS);
scb->payload_size = sizeof(psm_amarg_t) * (nargs-PSM_AM_HDR_QWORDS);
if (src != NULL && len > 0) {
psmi_mq_mtucpy((void *) bufp, src, len);
scb->payload_size += len;
}
scb->payload_size += pad_bytes;
scb->ips_lrh.hdr_dlen = pad_bytes;
goto send_scb;
}
}
/*
* If small enough, try to stuff the message in a header only
*/
if (len <= (hdr_qwords<<3)) { /* can handle len == 0 */
psmi_mq_mtucpy(&scb->ips_lrh.data[PSM_AM_HDR_QWORDS-hdr_qwords], src, len);
scb->payload_size = 0;
scb->ips_lrh.hdr_dlen = len;
scb->ips_lrh.amhdr_flags |= IPS_AMFLAG_ISTINY;
}
else { /* Whatever's left requires a separate payload */
if (scb->payload == NULL) { /* Just attach the buffer */
scb->payload = src;
}
else { /* May need to re-xmit user data, keep it around */
psmi_mq_mtucpy(scb->payload, src, len);
}
scb->payload_size = len + pad_bytes;
scb->ips_lrh.hdr_dlen = pad_bytes;
}
send_scb:
scb->ips_lrh.sub_opcode = sub_opcode;
flow->fn.xfer.enqueue(flow, scb);
flow->fn.xfer.flush(flow, NULL);
return PSM_OK;
}
static inline int
calculate_pad_bytes (struct ips_proto_am *proto_am, int nargs, size_t len)
{
if ((nargs <= PSM_AM_HDR_QWORDS) &&
(len <= ((PSM_AM_HDR_QWORDS - nargs) << 3)))
return 0;
else {
size_t arg_overflow = (nargs > PSM_AM_HDR_QWORDS) ?
(sizeof(psm_amarg_t) * (nargs - PSM_AM_HDR_QWORDS)) : 0;
size_t cache_aligned_len = (len + arg_overflow + PSM_CACHE_LINE_BYTES-1) &
~(PSM_CACHE_LINE_BYTES - 1);
if (cache_aligned_len <= proto_am->proto->scb_bufsize)
return cache_aligned_len - (len + arg_overflow);
else
return 0;
}
}
static inline
void
ips_am_scb_init(ips_scb_t *scb, uint8_t handler, int nargs,
int pad_bytes,
psm_am_completion_fn_t completion_fn,
void *completion_ctxt)
{
scb->completion_am = completion_fn;
scb->cb_param = completion_ctxt;
scb->ips_lrh.amhdr_hidx = handler;
scb->ips_lrh.hdr_dlen = pad_bytes;
scb->ips_lrh.amhdr_nargs = nargs;
scb->ips_lrh.amhdr_flags = 0;
if (completion_fn)
scb->flags |= IPS_SEND_FLAG_ACK_REQ;
return;
}
psm_error_t
ips_am_short_request(psm_epaddr_t epaddr,
psm_handler_t handler, psm_amarg_t *args, int nargs,
void *src, size_t len, int flags,
psm_am_completion_fn_t completion_fn,
void *completion_ctxt)
{
struct ips_proto_am *proto_am = &epaddr->ptl->proto.proto_am;
psm_error_t err;
ips_scb_t *scb;
int pad_bytes = calculate_pad_bytes(proto_am, nargs, len);
int payload_sz = (nargs << 3) + pad_bytes;
if_pt (!(flags & PSM_AM_FLAG_ASYNC))
payload_sz += len;
if (payload_sz > (PSM_AM_HDR_QWORDS << 3)) {
/* Payload can't fit in header - allocate buffer to carry data */
int arg_sz = (nargs > PSM_AM_HDR_QWORDS) ?
((nargs - PSM_AM_HDR_QWORDS) << 3) : 0;
/* len + pad_bytes + overflow_args */
PSMI_BLOCKUNTIL(epaddr->ep,err,
((scb = ips_scbctrl_alloc(proto_am->scbc_request, 1,
len + pad_bytes + arg_sz,
IPS_SCB_FLAG_ADD_BUFFER)) != NULL));
}
else {
PSMI_BLOCKUNTIL(epaddr->ep,err,
((scb = ips_scbctrl_alloc_tiny(proto_am->scbc_request)) != NULL));
}
psmi_assert_always(scb != NULL);
ips_am_scb_init(scb, handler, nargs, pad_bytes,
completion_fn, completion_ctxt);
return am_short_reqrep(proto_am, scb, epaddr->ptladdr, args, nargs,
(flags & PSM_AM_FLAG_NOREPLY) ?
OPCODE_AM_REQUEST_NOREPLY : OPCODE_AM_REQUEST,
src, len, flags, pad_bytes);
}
psm_error_t
ips_am_short_reply(psm_am_token_t tok,
psm_handler_t handler, psm_amarg_t *args, int nargs,
void *src, size_t len, int flags,
psm_am_completion_fn_t completion_fn,
void *completion_ctxt)
{
ips_scb_t *scb;
struct ips_am_token *token = (struct ips_am_token *) tok;
struct ips_proto_am *proto_am = token->proto_am;
struct ptl_epaddr *ipsaddr = token->tok.epaddr_from->ptladdr;
int scb_flags = 0;
int pad_bytes = calculate_pad_bytes(proto_am, nargs, len);
if (!token->tok.can_reply) {
/* Trying to reply for an AM request that did not expect a reply */
_IPATH_ERROR("Invalid AM reply for request!");
return PSM_AM_INVALID_REPLY;
}
psmi_assert_always(ips_scbctrl_avail(&proto_am->scbc_reply));
if ((nargs<<3) + len <= (PSM_AM_HDR_QWORDS<<3)) {
psmi_assert_always(pad_bytes == 0);
scb = ips_scbctrl_alloc_tiny(&proto_am->scbc_reply);
}
else {
int payload_sz = (nargs << 3) + pad_bytes;
payload_sz += (flags & PSM_AM_FLAG_ASYNC) ? 0 : len;
scb_flags |= (payload_sz > (PSM_AM_HDR_QWORDS << 3)) ?
IPS_SCB_FLAG_ADD_BUFFER : 0;
scb = ips_scbctrl_alloc(&proto_am->scbc_reply, 1, payload_sz, scb_flags);
}
psmi_assert_always(scb != NULL);
ips_am_scb_init(scb, handler, nargs, pad_bytes,
completion_fn, completion_ctxt);
am_short_reqrep(proto_am, scb, ipsaddr, args, nargs, OPCODE_AM_REPLY,
src, len, flags, pad_bytes);
return PSM_OK;
}
/* Prepares and runs a handler from a receive event. */
static int
ips_am_run_handler(struct ips_am_token *tok,
const struct ips_recvhdrq_event *rcv_ev)
{
struct ips_message_header *p_hdr = rcv_ev->p_hdr;
struct ips_proto_am *proto_am = &rcv_ev->proto->proto_am;
psm_am_handler_fn_t hfn;
int nargs = p_hdr->amhdr_nargs;
tok->tok.flags = p_hdr->amhdr_flags;
tok->tok.epaddr_from = rcv_ev->ipsaddr->epaddr;
tok->tok.can_reply = (p_hdr->sub_opcode == OPCODE_AM_REQUEST);
tok->proto_am = proto_am;
hfn = psm_am_get_handler_function(rcv_ev->proto->ep,
p_hdr->amhdr_hidx);
_IPATH_VDBG("amhdr_len=%d, amhdr_flags=%x, amhdr_nargs=%d, p_hdr=%p\n",
p_hdr->hdr_dlen, p_hdr->amhdr_flags, p_hdr->amhdr_nargs, p_hdr);
/* Fast path: everything fits only in a header */
if (tok->tok.flags & IPS_AMFLAG_ISTINY) {
return hfn(tok, tok->tok.epaddr_from,
(psm_amarg_t *) &p_hdr->data[0].u64, nargs,
&p_hdr->data[nargs].u64, p_hdr->hdr_dlen);
}
else {
/* Arguments and payload may split across header/eager_payload
* boundaries. */
psm_amarg_t args[8] = {};
int i;
uint64_t *payload = (uint64_t *) ips_recvhdrq_event_payload(rcv_ev);
uint32_t paylen = ips_recvhdrq_event_paylen(rcv_ev);
for (i = 0; i < nargs; i++) {
if (i < PSM_AM_HDR_QWORDS)
args[i].u64 = p_hdr->data[i].u64;
else {
args[i].u64 = *payload++;
paylen -= 8;
}
}
paylen -= p_hdr->hdr_dlen;
return hfn(tok, tok->tok.epaddr_from, args, nargs, payload, paylen);
}
}
int
ips_proto_am(struct ips_recvhdrq_event *rcv_ev)
{
struct ips_am_token token;
struct ips_message_header *p_hdr = rcv_ev->p_hdr;
struct ptl_epaddr *ipsaddr = rcv_ev->ipsaddr;
struct ips_proto_am *proto_am = &rcv_ev->proto->proto_am;
ptl_epaddr_flow_t flowid = ips_proto_flowid(p_hdr);
struct ips_flow *flow = &ipsaddr->flows[flowid];
int ret = IPS_RECVHDRQ_CONTINUE;
/*
* Based on AM request/reply traffic pattern, if we don't have
* a reply scb slot then we can't process the request packet,
* we just silently drop it. Otherwise, it will be a deadlock.
* note: ips_proto_is_expected_or_nak() can not be called in this case.
*/
if (p_hdr->sub_opcode == OPCODE_AM_REQUEST &&
!ips_scbctrl_avail(&proto_am->scbc_reply)) {
proto_am->amreply_nobufs++;
return ret;
}
if (ips_proto_is_expected_or_nak((struct ips_recvhdrq_event*) rcv_ev)) {
/* run handler */
if (ips_am_run_handler(&token, rcv_ev))
ret = IPS_RECVHDRQ_BREAK;
/* Look if the handler replied, if it didn't, ack the request */
if ((p_hdr->flags & IPS_SEND_FLAG_ACK_REQ) ||
(flow->flags & IPS_FLOW_FLAG_GEN_BECN))
ips_proto_send_ack((struct ips_recvhdrq *) rcv_ev->recvq, flow);
}
ips_proto_process_ack(rcv_ev);
return ret;
}
|
01org/psm
|
ptl_ips/ips_proto_am.c
|
C
|
gpl-2.0
| 11,869 |
# Wheelchair_UCO
Software engineering II final project
|
GaribottiUCO/Wheelchair_UCO
|
Wheelchair_UCO-master/README.md
|
Markdown
|
gpl-2.0
| 55 |
/*
* linux/fs/jbd2/journal.c
*
* Written by Stephen C. Tweedie <[email protected]>, 1998
*
* Copyright 1998 Red Hat corp --- All Rights Reserved
*
* This file is part of the Linux kernel and is made available under
* the terms of the GNU General Public License, version 2, or at your
* option, any later version, incorporated herein by reference.
*
* Generic filesystem journal-writing code; part of the ext2fs
* journaling system.
*
* This file manages journals: areas of disk reserved for logging
* transactional updates. This includes the kernel journaling thread
* which is responsible for scheduling updates to the log.
*
* We do not actually manage the physical storage of the journal in this
* file: that is left to a per-journal policy function, which allows us
* to store the journal within a filesystem-specified area for ext2
* journaling (ext2 can use a reserved inode for storing the log).
*/
#include <linux/module.h>
#include <linux/time.h>
#include <linux/fs.h>
#include <linux/jbd2.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/freezer.h>
#include <linux/pagemap.h>
#include <linux/kthread.h>
#include <linux/poison.h>
#include <linux/proc_fs.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/math64.h>
#include <linux/hash.h>
#include <linux/log2.h>
#include <linux/vmalloc.h>
#include <linux/backing-dev.h>
#include <linux/bitops.h>
#include <linux/ratelimit.h>
#define CREATE_TRACE_POINTS
#include <trace/events/jbd2.h>
#include <asm/uaccess.h>
#include <asm/page.h>
EXPORT_SYMBOL(jbd2_journal_extend);
EXPORT_SYMBOL(jbd2_journal_stop);
EXPORT_SYMBOL(jbd2_journal_lock_updates);
EXPORT_SYMBOL(jbd2_journal_unlock_updates);
EXPORT_SYMBOL(jbd2_journal_get_write_access);
EXPORT_SYMBOL(jbd2_journal_get_create_access);
EXPORT_SYMBOL(jbd2_journal_get_undo_access);
EXPORT_SYMBOL(jbd2_journal_set_triggers);
EXPORT_SYMBOL(jbd2_journal_dirty_metadata);
EXPORT_SYMBOL(jbd2_journal_release_buffer);
EXPORT_SYMBOL(jbd2_journal_forget);
#if 0
EXPORT_SYMBOL(journal_sync_buffer);
#endif
EXPORT_SYMBOL(jbd2_journal_flush);
EXPORT_SYMBOL(jbd2_journal_revoke);
EXPORT_SYMBOL(jbd2_journal_init_dev);
EXPORT_SYMBOL(jbd2_journal_init_inode);
EXPORT_SYMBOL(jbd2_journal_check_used_features);
EXPORT_SYMBOL(jbd2_journal_check_available_features);
EXPORT_SYMBOL(jbd2_journal_set_features);
EXPORT_SYMBOL(jbd2_journal_load);
EXPORT_SYMBOL(jbd2_journal_destroy);
EXPORT_SYMBOL(jbd2_journal_abort);
EXPORT_SYMBOL(jbd2_journal_errno);
EXPORT_SYMBOL(jbd2_journal_ack_err);
EXPORT_SYMBOL(jbd2_journal_clear_err);
EXPORT_SYMBOL(jbd2_log_wait_commit);
EXPORT_SYMBOL(jbd2_log_start_commit);
EXPORT_SYMBOL(jbd2_journal_start_commit);
EXPORT_SYMBOL(jbd2_journal_force_commit_nested);
EXPORT_SYMBOL(jbd2_journal_wipe);
EXPORT_SYMBOL(jbd2_journal_blocks_per_page);
EXPORT_SYMBOL(jbd2_journal_invalidatepage);
EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
EXPORT_SYMBOL(jbd2_journal_force_commit);
EXPORT_SYMBOL(jbd2_journal_file_inode);
EXPORT_SYMBOL(jbd2_journal_init_jbd_inode);
EXPORT_SYMBOL(jbd2_journal_release_jbd_inode);
EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate);
EXPORT_SYMBOL(jbd2_inode_cache);
static void __journal_abort_soft (journal_t *journal, int errno);
static int jbd2_journal_create_slab(size_t slab_size);
/*
* Helper function used to manage commit timeouts
*/
static void commit_timeout(unsigned long __data)
{
struct task_struct * p = (struct task_struct *) __data;
wake_up_process(p);
}
/*
* kjournald2: The main thread function used to manage a logging device
* journal.
*
* This kernel thread is responsible for two things:
*
* 1) COMMIT: Every so often we need to commit the current state of the
* filesystem to disk. The journal thread is responsible for writing
* all of the metadata buffers to disk.
*
* 2) CHECKPOINT: We cannot reuse a used section of the log file until all
* of the data in that part of the log has been rewritten elsewhere on
* the disk. Flushing these old buffers to reclaim space in the log is
* known as checkpointing, and this thread is responsible for that job.
*/
static int kjournald2(void *arg)
{
journal_t *journal = arg;
transaction_t *transaction;
/*
* Set up an interval timer which can be used to trigger a commit wakeup
* after the commit interval expires
*/
setup_timer(&journal->j_commit_timer, commit_timeout,
(unsigned long)current);
set_freezable();
/* Record that the journal thread is running */
journal->j_task = current;
wake_up(&journal->j_wait_done_commit);
/*
* And now, wait forever for commit wakeup events.
*/
write_lock(&journal->j_state_lock);
loop:
if (journal->j_flags & JBD2_UNMOUNT)
goto end_loop;
jbd_debug(1, "commit_sequence=%d, commit_request=%d\n",
journal->j_commit_sequence, journal->j_commit_request);
if (journal->j_commit_sequence != journal->j_commit_request) {
jbd_debug(1, "OK, requests differ\n");
write_unlock(&journal->j_state_lock);
del_timer_sync(&journal->j_commit_timer);
jbd2_journal_commit_transaction(journal);
write_lock(&journal->j_state_lock);
goto loop;
}
wake_up(&journal->j_wait_done_commit);
if (freezing(current)) {
/*
* The simpler the better. Flushing journal isn't a
* good idea, because that depends on threads that may
* be already stopped.
*/
jbd_debug(1, "Now suspending kjournald2\n");
write_unlock(&journal->j_state_lock);
try_to_freeze();
write_lock(&journal->j_state_lock);
} else {
/*
* We assume on resume that commits are already there,
* so we don't sleep
*/
DEFINE_WAIT(wait);
int should_sleep = 1;
prepare_to_wait(&journal->j_wait_commit, &wait,
TASK_INTERRUPTIBLE);
if (journal->j_commit_sequence != journal->j_commit_request)
should_sleep = 0;
transaction = journal->j_running_transaction;
if (transaction && time_after_eq(jiffies,
transaction->t_expires))
should_sleep = 0;
if (journal->j_flags & JBD2_UNMOUNT)
should_sleep = 0;
if (should_sleep) {
write_unlock(&journal->j_state_lock);
schedule();
write_lock(&journal->j_state_lock);
}
finish_wait(&journal->j_wait_commit, &wait);
}
jbd_debug(1, "kjournald2 wakes\n");
/*
* Were we woken up by a commit wakeup event?
*/
transaction = journal->j_running_transaction;
if (transaction && time_after_eq(jiffies, transaction->t_expires)) {
journal->j_commit_request = transaction->t_tid;
jbd_debug(1, "woke because of timeout\n");
}
goto loop;
end_loop:
write_unlock(&journal->j_state_lock);
del_timer_sync(&journal->j_commit_timer);
journal->j_task = NULL;
wake_up(&journal->j_wait_done_commit);
jbd_debug(1, "Journal thread exiting.\n");
return 0;
}
static int jbd2_journal_start_thread(journal_t *journal)
{
struct task_struct *t;
t = kthread_run(kjournald2, journal, "jbd2/%s",
journal->j_devname);
if (IS_ERR(t))
return PTR_ERR(t);
wait_event(journal->j_wait_done_commit, journal->j_task != NULL);
return 0;
}
static void journal_kill_thread(journal_t *journal)
{
write_lock(&journal->j_state_lock);
journal->j_flags |= JBD2_UNMOUNT;
while (journal->j_task) {
wake_up(&journal->j_wait_commit);
write_unlock(&journal->j_state_lock);
wait_event(journal->j_wait_done_commit, journal->j_task == NULL);
write_lock(&journal->j_state_lock);
}
write_unlock(&journal->j_state_lock);
}
/*
* jbd2_journal_write_metadata_buffer: write a metadata buffer to the journal.
*
* Writes a metadata buffer to a given disk block. The actual IO is not
* performed but a new buffer_head is constructed which labels the data
* to be written with the correct destination disk block.
*
* Any magic-number escaping which needs to be done will cause a
* copy-out here. If the buffer happens to start with the
* JBD2_MAGIC_NUMBER, then we can't write it to the log directly: the
* magic number is only written to the log for descripter blocks. In
* this case, we copy the data and replace the first word with 0, and we
* return a result code which indicates that this buffer needs to be
* marked as an escaped buffer in the corresponding log descriptor
* block. The missing word can then be restored when the block is read
* during recovery.
*
* If the source buffer has already been modified by a new transaction
* since we took the last commit snapshot, we use the frozen copy of
* that data for IO. If we end up using the existing buffer_head's data
* for the write, then we *have* to lock the buffer to prevent anyone
* else from using and possibly modifying it while the IO is in
* progress.
*
* The function returns a pointer to the buffer_heads to be used for IO.
*
* We assume that the journal has already been locked in this function.
*
* Return value:
* <0: Error
* >=0: Finished OK
*
* On success:
* Bit 0 set == escape performed on the data
* Bit 1 set == buffer copy-out performed (kfree the data after IO)
*/
int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
struct journal_head *jh_in,
struct journal_head **jh_out,
unsigned long long blocknr)
{
int need_copy_out = 0;
int done_copy_out = 0;
int do_escape = 0;
char *mapped_data;
struct buffer_head *new_bh;
struct journal_head *new_jh;
struct page *new_page;
unsigned int new_offset;
struct buffer_head *bh_in = jh2bh(jh_in);
journal_t *journal = transaction->t_journal;
/*
* The buffer really shouldn't be locked: only the current committing
* transaction is allowed to write it, so nobody else is allowed
* to do any IO.
*
* akpm: except if we're journalling data, and write() output is
* also part of a shared mapping, and another thread has
* decided to launch a writepage() against this buffer.
*/
J_ASSERT_BH(bh_in, buffer_jbddirty(bh_in));
retry_alloc:
new_bh = alloc_buffer_head(GFP_NOFS);
if (!new_bh) {
/*
* Failure is not an option, but __GFP_NOFAIL is going
* away; so we retry ourselves here.
*/
congestion_wait(BLK_RW_ASYNC, HZ/50);
goto retry_alloc;
}
/* keep subsequent assertions sane */
new_bh->b_state = 0;
init_buffer(new_bh, NULL, NULL);
atomic_set(&new_bh->b_count, 1);
new_jh = jbd2_journal_add_journal_head(new_bh); /* This sleeps */
/*
* If a new transaction has already done a buffer copy-out, then
* we use that version of the data for the commit.
*/
jbd_lock_bh_state(bh_in);
repeat:
if (jh_in->b_frozen_data) {
done_copy_out = 1;
new_page = virt_to_page(jh_in->b_frozen_data);
new_offset = offset_in_page(jh_in->b_frozen_data);
} else {
new_page = jh2bh(jh_in)->b_page;
new_offset = offset_in_page(jh2bh(jh_in)->b_data);
}
mapped_data = kmap_atomic(new_page);
/*
* Fire data frozen trigger if data already wasn't frozen. Do this
* before checking for escaping, as the trigger may modify the magic
* offset. If a copy-out happens afterwards, it will have the correct
* data in the buffer.
*/
if (!done_copy_out)
jbd2_buffer_frozen_trigger(jh_in, mapped_data + new_offset,
jh_in->b_triggers);
/*
* Check for escaping
*/
if (*((__be32 *)(mapped_data + new_offset)) ==
cpu_to_be32(JBD2_MAGIC_NUMBER)) {
need_copy_out = 1;
do_escape = 1;
}
kunmap_atomic(mapped_data);
/*
* Do we need to do a data copy?
*/
if (need_copy_out && !done_copy_out) {
char *tmp;
jbd_unlock_bh_state(bh_in);
tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS);
if (!tmp) {
jbd2_journal_put_journal_head(new_jh);
return -ENOMEM;
}
jbd_lock_bh_state(bh_in);
if (jh_in->b_frozen_data) {
jbd2_free(tmp, bh_in->b_size);
goto repeat;
}
jh_in->b_frozen_data = tmp;
mapped_data = kmap_atomic(new_page);
memcpy(tmp, mapped_data + new_offset, jh2bh(jh_in)->b_size);
kunmap_atomic(mapped_data);
new_page = virt_to_page(tmp);
new_offset = offset_in_page(tmp);
done_copy_out = 1;
/*
* This isn't strictly necessary, as we're using frozen
* data for the escaping, but it keeps consistency with
* b_frozen_data usage.
*/
jh_in->b_frozen_triggers = jh_in->b_triggers;
}
/*
* Did we need to do an escaping? Now we've done all the
* copying, we can finally do so.
*/
if (do_escape) {
mapped_data = kmap_atomic(new_page);
*((unsigned int *)(mapped_data + new_offset)) = 0;
kunmap_atomic(mapped_data);
}
set_bh_page(new_bh, new_page, new_offset);
new_jh->b_transaction = NULL;
new_bh->b_size = jh2bh(jh_in)->b_size;
new_bh->b_bdev = transaction->t_journal->j_dev;
new_bh->b_blocknr = blocknr;
set_buffer_mapped(new_bh);
set_buffer_dirty(new_bh);
*jh_out = new_jh;
/*
* The to-be-written buffer needs to get moved to the io queue,
* and the original buffer whose contents we are shadowing or
* copying is moved to the transaction's shadow queue.
*/
JBUFFER_TRACE(jh_in, "file as BJ_Shadow");
spin_lock(&journal->j_list_lock);
__jbd2_journal_file_buffer(jh_in, transaction, BJ_Shadow);
spin_unlock(&journal->j_list_lock);
jbd_unlock_bh_state(bh_in);
JBUFFER_TRACE(new_jh, "file as BJ_IO");
jbd2_journal_file_buffer(new_jh, transaction, BJ_IO);
return do_escape | (done_copy_out << 1);
}
/*
* Allocation code for the journal file. Manage the space left in the
* journal, so that we can begin checkpointing when appropriate.
*/
/*
* __jbd2_log_space_left: Return the number of free blocks left in the journal.
*
* Called with the journal already locked.
*
* Called under j_state_lock
*/
int __jbd2_log_space_left(journal_t *journal)
{
int left = journal->j_free;
/* assert_spin_locked(&journal->j_state_lock); */
/*
* Be pessimistic here about the number of those free blocks which
* might be required for log descriptor control blocks.
*/
#define MIN_LOG_RESERVED_BLOCKS 32 /* Allow for rounding errors */
left -= MIN_LOG_RESERVED_BLOCKS;
if (left <= 0)
return 0;
left -= (left >> 3);
return left;
}
/*
* Called with j_state_lock locked for writing.
* Returns true if a transaction commit was started.
*/
int __jbd2_log_start_commit(journal_t *journal, tid_t target)
{
/*
* The only transaction we can possibly wait upon is the
* currently running transaction (if it exists). Otherwise,
* the target tid must be an old one.
*/
if (journal->j_running_transaction &&
journal->j_running_transaction->t_tid == target) {
/*
* We want a new commit: OK, mark the request and wakeup the
* commit thread. We do _not_ do the commit ourselves.
*/
journal->j_commit_request = target;
jbd_debug(1, "JBD2: requesting commit %d/%d\n",
journal->j_commit_request,
journal->j_commit_sequence);
wake_up(&journal->j_wait_commit);
return 1;
} else if (!tid_geq(journal->j_commit_request, target))
/* This should never happen, but if it does, preserve
the evidence before kjournald goes into a loop and
increments j_commit_sequence beyond all recognition. */
WARN_ONCE(1, "JBD2: bad log_start_commit: %u %u %u %u\n",
journal->j_commit_request,
journal->j_commit_sequence,
target, journal->j_running_transaction ?
journal->j_running_transaction->t_tid : 0);
return 0;
}
int jbd2_log_start_commit(journal_t *journal, tid_t tid)
{
int ret;
write_lock(&journal->j_state_lock);
ret = __jbd2_log_start_commit(journal, tid);
write_unlock(&journal->j_state_lock);
return ret;
}
/*
* Force and wait any uncommitted transactions. We can only force the running
* transaction if we don't have an active handle, otherwise, we will deadlock.
* Returns: <0 in case of error,
* 0 if nothing to commit,
* 1 if transaction was successfully committed.
*/
static int __jbd2_journal_force_commit(journal_t *journal)
{
transaction_t *transaction = NULL;
tid_t tid;
int need_to_start = 0, ret = 0;
read_lock(&journal->j_state_lock);
if (journal->j_running_transaction && !current->journal_info) {
transaction = journal->j_running_transaction;
if (!tid_geq(journal->j_commit_request, transaction->t_tid))
need_to_start = 1;
} else if (journal->j_committing_transaction)
transaction = journal->j_committing_transaction;
if (!transaction) {
/* Nothing to commit */
read_unlock(&journal->j_state_lock);
return 0;
}
tid = transaction->t_tid;
read_unlock(&journal->j_state_lock);
if (need_to_start)
jbd2_log_start_commit(journal, tid);
ret = jbd2_log_wait_commit(journal, tid);
if (!ret)
ret = 1;
return ret;
}
/**
* Force and wait upon a commit if the calling process is not within
* transaction. This is used for forcing out undo-protected data which contains
* bitmaps, when the fs is running out of space.
*
* @journal: journal to force
* Returns true if progress was made.
*/
int jbd2_journal_force_commit_nested(journal_t *journal)
{
int ret;
ret = __jbd2_journal_force_commit(journal);
return ret > 0;
}
/**
* int journal_force_commit() - force any uncommitted transactions
* @journal: journal to force
*
* Caller want unconditional commit. We can only force the running transaction
* if we don't have an active handle, otherwise, we will deadlock.
*/
int jbd2_journal_force_commit(journal_t *journal)
{
int ret;
J_ASSERT(!current->journal_info);
ret = __jbd2_journal_force_commit(journal);
if (ret > 0)
ret = 0;
return ret;
}
/*
* Start a commit of the current running transaction (if any). Returns true
* if a transaction is going to be committed (or is currently already
* committing), and fills its tid in at *ptid
*/
int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid)
{
int ret = 0;
write_lock(&journal->j_state_lock);
if (journal->j_running_transaction) {
tid_t tid = journal->j_running_transaction->t_tid;
__jbd2_log_start_commit(journal, tid);
/* There's a running transaction and we've just made sure
* it's commit has been scheduled. */
if (ptid)
*ptid = tid;
ret = 1;
} else if (journal->j_committing_transaction) {
/*
* If ext3_write_super() recently started a commit, then we
* have to wait for completion of that transaction
*/
if (ptid)
*ptid = journal->j_committing_transaction->t_tid;
ret = 1;
}
write_unlock(&journal->j_state_lock);
return ret;
}
/*
* Return 1 if a given transaction has not yet sent barrier request
* connected with a transaction commit. If 0 is returned, transaction
* may or may not have sent the barrier. Used to avoid sending barrier
* twice in common cases.
*/
int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid)
{
int ret = 0;
transaction_t *commit_trans;
if (!(journal->j_flags & JBD2_BARRIER))
return 0;
read_lock(&journal->j_state_lock);
/* Transaction already committed? */
if (tid_geq(journal->j_commit_sequence, tid))
goto out;
commit_trans = journal->j_committing_transaction;
if (!commit_trans || commit_trans->t_tid != tid) {
ret = 1;
goto out;
}
/*
* Transaction is being committed and we already proceeded to
* submitting a flush to fs partition?
*/
if (journal->j_fs_dev != journal->j_dev) {
if (!commit_trans->t_need_data_flush ||
commit_trans->t_state >= T_COMMIT_DFLUSH)
goto out;
} else {
if (commit_trans->t_state >= T_COMMIT_JFLUSH)
goto out;
}
ret = 1;
out:
read_unlock(&journal->j_state_lock);
return ret;
}
EXPORT_SYMBOL(jbd2_trans_will_send_data_barrier);
/*
* Wait for a specified commit to complete.
* The caller may not hold the journal lock.
*/
int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
{
int err = 0;
read_lock(&journal->j_state_lock);
#ifdef CONFIG_JBD2_DEBUG
if (!tid_geq(journal->j_commit_request, tid)) {
printk(KERN_EMERG
"%s: error: j_commit_request=%d, tid=%d\n",
__func__, journal->j_commit_request, tid);
}
#endif
while (tid_gt(tid, journal->j_commit_sequence)) {
jbd_debug(1, "JBD2: want %d, j_commit_sequence=%d\n",
tid, journal->j_commit_sequence);
wake_up(&journal->j_wait_commit);
read_unlock(&journal->j_state_lock);
wait_event(journal->j_wait_done_commit,
!tid_gt(tid, journal->j_commit_sequence));
read_lock(&journal->j_state_lock);
}
read_unlock(&journal->j_state_lock);
if (unlikely(is_journal_aborted(journal))) {
printk(KERN_EMERG "journal commit I/O error\n");
err = -EIO;
}
return err;
}
/*
* Log buffer allocation routines:
*/
int jbd2_journal_next_log_block(journal_t *journal, unsigned long long *retp)
{
unsigned long blocknr;
write_lock(&journal->j_state_lock);
J_ASSERT(journal->j_free > 1);
blocknr = journal->j_head;
journal->j_head++;
journal->j_free--;
if (journal->j_head == journal->j_last)
journal->j_head = journal->j_first;
write_unlock(&journal->j_state_lock);
return jbd2_journal_bmap(journal, blocknr, retp);
}
/*
* Conversion of logical to physical block numbers for the journal
*
* On external journals the journal blocks are identity-mapped, so
* this is a no-op. If needed, we can use j_blk_offset - everything is
* ready.
*/
int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr,
unsigned long long *retp)
{
int err = 0;
unsigned long long ret;
if (journal->j_inode) {
ret = bmap(journal->j_inode, blocknr);
if (ret)
*retp = ret;
else {
printk(KERN_ALERT "%s: journal block not found "
"at offset %lu on %s\n",
__func__, blocknr, journal->j_devname);
err = -EIO;
__journal_abort_soft(journal, err);
}
} else {
*retp = blocknr; /* +journal->j_blk_offset */
}
return err;
}
/*
* We play buffer_head aliasing tricks to write data/metadata blocks to
* the journal without copying their contents, but for journal
* descriptor blocks we do need to generate bona fide buffers.
*
* After the caller of jbd2_journal_get_descriptor_buffer() has finished modifying
* the buffer's contents they really should run flush_dcache_page(bh->b_page).
* But we don't bother doing that, so there will be coherency problems with
* mmaps of blockdevs which hold live JBD-controlled filesystems.
*/
struct journal_head *jbd2_journal_get_descriptor_buffer(journal_t *journal)
{
struct buffer_head *bh;
unsigned long long blocknr;
int err;
err = jbd2_journal_next_log_block(journal, &blocknr);
if (err)
return NULL;
bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
if (!bh)
return NULL;
lock_buffer(bh);
memset(bh->b_data, 0, journal->j_blocksize);
set_buffer_uptodate(bh);
unlock_buffer(bh);
BUFFER_TRACE(bh, "return this buffer");
return jbd2_journal_add_journal_head(bh);
}
/*
* Return tid of the oldest transaction in the journal and block in the journal
* where the transaction starts.
*
* If the journal is now empty, return which will be the next transaction ID
* we will write and where will that transaction start.
*
* The return value is 0 if journal tail cannot be pushed any further, 1 if
* it can.
*/
int jbd2_journal_get_log_tail(journal_t *journal, tid_t *tid,
unsigned long *block)
{
transaction_t *transaction;
int ret;
read_lock(&journal->j_state_lock);
spin_lock(&journal->j_list_lock);
transaction = journal->j_checkpoint_transactions;
if (transaction) {
*tid = transaction->t_tid;
*block = transaction->t_log_start;
} else if ((transaction = journal->j_committing_transaction) != NULL) {
*tid = transaction->t_tid;
*block = transaction->t_log_start;
} else if ((transaction = journal->j_running_transaction) != NULL) {
*tid = transaction->t_tid;
*block = journal->j_head;
} else {
*tid = journal->j_transaction_sequence;
*block = journal->j_head;
}
ret = tid_gt(*tid, journal->j_tail_sequence);
spin_unlock(&journal->j_list_lock);
read_unlock(&journal->j_state_lock);
return ret;
}
/*
* Update information in journal structure and in on disk journal superblock
* about log tail. This function does not check whether information passed in
* really pushes log tail further. It's responsibility of the caller to make
* sure provided log tail information is valid (e.g. by holding
* j_checkpoint_mutex all the time between computing log tail and calling this
* function as is the case with jbd2_cleanup_journal_tail()).
*
* Requires j_checkpoint_mutex
*/
void __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
{
unsigned long freed;
BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
/*
* We cannot afford for write to remain in drive's caches since as
* soon as we update j_tail, next transaction can start reusing journal
* space and if we lose sb update during power failure we'd replay
* old transaction with possibly newly overwritten data.
*/
jbd2_journal_update_sb_log_tail(journal, tid, block, WRITE_FUA);
write_lock(&journal->j_state_lock);
freed = block - journal->j_tail;
if (block < journal->j_tail)
freed += journal->j_last - journal->j_first;
trace_jbd2_update_log_tail(journal, tid, block, freed);
jbd_debug(1,
"Cleaning journal tail from %d to %d (offset %lu), "
"freeing %lu\n",
journal->j_tail_sequence, tid, block, freed);
journal->j_free += freed;
journal->j_tail_sequence = tid;
journal->j_tail = block;
write_unlock(&journal->j_state_lock);
}
/*
* This is a variaon of __jbd2_update_log_tail which checks for validity of
* provided log tail and locks j_checkpoint_mutex. So it is safe against races
* with other threads updating log tail.
*/
void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
{
mutex_lock(&journal->j_checkpoint_mutex);
if (tid_gt(tid, journal->j_tail_sequence))
__jbd2_update_log_tail(journal, tid, block);
mutex_unlock(&journal->j_checkpoint_mutex);
}
struct jbd2_stats_proc_session {
journal_t *journal;
struct transaction_stats_s *stats;
int start;
int max;
};
static void *jbd2_seq_info_start(struct seq_file *seq, loff_t *pos)
{
return *pos ? NULL : SEQ_START_TOKEN;
}
static void *jbd2_seq_info_next(struct seq_file *seq, void *v, loff_t *pos)
{
return NULL;
}
static int jbd2_seq_info_show(struct seq_file *seq, void *v)
{
struct jbd2_stats_proc_session *s = seq->private;
if (v != SEQ_START_TOKEN)
return 0;
seq_printf(seq, "%lu transaction, each up to %u blocks\n",
s->stats->ts_tid,
s->journal->j_max_transaction_buffers);
if (s->stats->ts_tid == 0)
return 0;
seq_printf(seq, "average: \n %ums waiting for transaction\n",
jiffies_to_msecs(s->stats->run.rs_wait / s->stats->ts_tid));
seq_printf(seq, " %ums running transaction\n",
jiffies_to_msecs(s->stats->run.rs_running / s->stats->ts_tid));
seq_printf(seq, " %ums transaction was being locked\n",
jiffies_to_msecs(s->stats->run.rs_locked / s->stats->ts_tid));
seq_printf(seq, " %ums flushing data (in ordered mode)\n",
jiffies_to_msecs(s->stats->run.rs_flushing / s->stats->ts_tid));
seq_printf(seq, " %ums logging transaction\n",
jiffies_to_msecs(s->stats->run.rs_logging / s->stats->ts_tid));
seq_printf(seq, " %lluus average transaction commit time\n",
div_u64(s->journal->j_average_commit_time, 1000));
seq_printf(seq, " %lu handles per transaction\n",
s->stats->run.rs_handle_count / s->stats->ts_tid);
seq_printf(seq, " %lu blocks per transaction\n",
s->stats->run.rs_blocks / s->stats->ts_tid);
seq_printf(seq, " %lu logged blocks per transaction\n",
s->stats->run.rs_blocks_logged / s->stats->ts_tid);
return 0;
}
static void jbd2_seq_info_stop(struct seq_file *seq, void *v)
{
}
static const struct seq_operations jbd2_seq_info_ops = {
.start = jbd2_seq_info_start,
.next = jbd2_seq_info_next,
.stop = jbd2_seq_info_stop,
.show = jbd2_seq_info_show,
};
static int jbd2_seq_info_open(struct inode *inode, struct file *file)
{
journal_t *journal = PDE(inode)->data;
struct jbd2_stats_proc_session *s;
int rc, size;
s = kmalloc(sizeof(*s), GFP_KERNEL);
if (s == NULL)
return -ENOMEM;
size = sizeof(struct transaction_stats_s);
s->stats = kmalloc(size, GFP_KERNEL);
if (s->stats == NULL) {
kfree(s);
return -ENOMEM;
}
spin_lock(&journal->j_history_lock);
memcpy(s->stats, &journal->j_stats, size);
s->journal = journal;
spin_unlock(&journal->j_history_lock);
rc = seq_open(file, &jbd2_seq_info_ops);
if (rc == 0) {
struct seq_file *m = file->private_data;
m->private = s;
} else {
kfree(s->stats);
kfree(s);
}
return rc;
}
static int jbd2_seq_info_release(struct inode *inode, struct file *file)
{
struct seq_file *seq = file->private_data;
struct jbd2_stats_proc_session *s = seq->private;
kfree(s->stats);
kfree(s);
return seq_release(inode, file);
}
static const struct file_operations jbd2_seq_info_fops = {
.owner = THIS_MODULE,
.open = jbd2_seq_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = jbd2_seq_info_release,
};
static struct proc_dir_entry *proc_jbd2_stats;
static void jbd2_stats_proc_init(journal_t *journal)
{
journal->j_proc_entry = proc_mkdir(journal->j_devname, proc_jbd2_stats);
if (journal->j_proc_entry) {
proc_create_data("info", S_IRUGO, journal->j_proc_entry,
&jbd2_seq_info_fops, journal);
}
}
static void jbd2_stats_proc_exit(journal_t *journal)
{
remove_proc_entry("info", journal->j_proc_entry);
remove_proc_entry(journal->j_devname, proc_jbd2_stats);
}
/*
* Management for journal control blocks: functions to create and
* destroy journal_t structures, and to initialise and read existing
* journal blocks from disk. */
/* First: create and setup a journal_t object in memory. We initialise
* very few fields yet: that has to wait until we have created the
* journal structures from from scratch, or loaded them from disk. */
static journal_t * journal_init_common (void)
{
journal_t *journal;
int err;
journal = kzalloc(sizeof(*journal), GFP_KERNEL);
if (!journal)
return NULL;
init_waitqueue_head(&journal->j_wait_transaction_locked);
init_waitqueue_head(&journal->j_wait_logspace);
init_waitqueue_head(&journal->j_wait_done_commit);
init_waitqueue_head(&journal->j_wait_checkpoint);
init_waitqueue_head(&journal->j_wait_commit);
init_waitqueue_head(&journal->j_wait_updates);
mutex_init(&journal->j_barrier);
mutex_init(&journal->j_checkpoint_mutex);
spin_lock_init(&journal->j_revoke_lock);
spin_lock_init(&journal->j_list_lock);
rwlock_init(&journal->j_state_lock);
journal->j_commit_interval = (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE);
journal->j_min_batch_time = 0;
journal->j_max_batch_time = 15000; /* 15ms */
/* The journal is marked for error until we succeed with recovery! */
journal->j_flags = JBD2_ABORT;
/* Set up a default-sized revoke table for the new mount. */
err = jbd2_journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH);
if (err) {
kfree(journal);
return NULL;
}
spin_lock_init(&journal->j_history_lock);
return journal;
}
/* jbd2_journal_init_dev and jbd2_journal_init_inode:
*
* Create a journal structure assigned some fixed set of disk blocks to
* the journal. We don't actually touch those disk blocks yet, but we
* need to set up all of the mapping information to tell the journaling
* system where the journal blocks are.
*
*/
/**
* journal_t * jbd2_journal_init_dev() - creates and initialises a journal structure
* @bdev: Block device on which to create the journal
* @fs_dev: Device which hold journalled filesystem for this journal.
* @start: Block nr Start of journal.
* @len: Length of the journal in blocks.
* @blocksize: blocksize of journalling device
*
* Returns: a newly created journal_t *
*
* jbd2_journal_init_dev creates a journal which maps a fixed contiguous
* range of blocks on an arbitrary block device.
*
*/
journal_t * jbd2_journal_init_dev(struct block_device *bdev,
struct block_device *fs_dev,
unsigned long long start, int len, int blocksize)
{
journal_t *journal = journal_init_common();
struct buffer_head *bh;
char *p;
int n;
if (!journal)
return NULL;
/* journal descriptor can store up to n blocks -bzzz */
journal->j_blocksize = blocksize;
journal->j_dev = bdev;
journal->j_fs_dev = fs_dev;
journal->j_blk_offset = start;
journal->j_maxlen = len;
bdevname(journal->j_dev, journal->j_devname);
p = journal->j_devname;
while ((p = strchr(p, '/')))
*p = '!';
jbd2_stats_proc_init(journal);
n = journal->j_blocksize / sizeof(journal_block_tag_t);
journal->j_wbufsize = n;
journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL);
if (!journal->j_wbuf) {
printk(KERN_ERR "%s: Can't allocate bhs for commit thread\n",
__func__);
goto out_err;
}
bh = __getblk(journal->j_dev, start, journal->j_blocksize);
if (!bh) {
printk(KERN_ERR
"%s: Cannot get buffer for journal superblock\n",
__func__);
goto out_err;
}
journal->j_sb_buffer = bh;
journal->j_superblock = (journal_superblock_t *)bh->b_data;
return journal;
out_err:
kfree(journal->j_wbuf);
jbd2_stats_proc_exit(journal);
kfree(journal);
return NULL;
}
/**
* journal_t * jbd2_journal_init_inode () - creates a journal which maps to a inode.
* @inode: An inode to create the journal in
*
* jbd2_journal_init_inode creates a journal which maps an on-disk inode as
* the journal. The inode must exist already, must support bmap() and
* must have all data blocks preallocated.
*/
journal_t * jbd2_journal_init_inode (struct inode *inode)
{
struct buffer_head *bh;
journal_t *journal = journal_init_common();
char *p;
int err;
int n;
unsigned long long blocknr;
if (!journal)
return NULL;
journal->j_dev = journal->j_fs_dev = inode->i_sb->s_bdev;
journal->j_inode = inode;
bdevname(journal->j_dev, journal->j_devname);
p = journal->j_devname;
while ((p = strchr(p, '/')))
*p = '!';
p = journal->j_devname + strlen(journal->j_devname);
sprintf(p, "-%lu", journal->j_inode->i_ino);
jbd_debug(1,
"journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n",
journal, inode->i_sb->s_id, inode->i_ino,
(long long) inode->i_size,
inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize);
journal->j_maxlen = inode->i_size >> inode->i_sb->s_blocksize_bits;
journal->j_blocksize = inode->i_sb->s_blocksize;
jbd2_stats_proc_init(journal);
/* journal descriptor can store up to n blocks -bzzz */
n = journal->j_blocksize / sizeof(journal_block_tag_t);
journal->j_wbufsize = n;
journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL);
if (!journal->j_wbuf) {
printk(KERN_ERR "%s: Can't allocate bhs for commit thread\n",
__func__);
goto out_err;
}
err = jbd2_journal_bmap(journal, 0, &blocknr);
/* If that failed, give up */
if (err) {
printk(KERN_ERR "%s: Cannot locate journal superblock\n",
__func__);
goto out_err;
}
bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
if (!bh) {
printk(KERN_ERR
"%s: Cannot get buffer for journal superblock\n",
__func__);
goto out_err;
}
journal->j_sb_buffer = bh;
journal->j_superblock = (journal_superblock_t *)bh->b_data;
return journal;
out_err:
kfree(journal->j_wbuf);
jbd2_stats_proc_exit(journal);
kfree(journal);
return NULL;
}
/*
* If the journal init or create aborts, we need to mark the journal
* superblock as being NULL to prevent the journal destroy from writing
* back a bogus superblock.
*/
static void journal_fail_superblock (journal_t *journal)
{
struct buffer_head *bh = journal->j_sb_buffer;
brelse(bh);
journal->j_sb_buffer = NULL;
}
/*
* Given a journal_t structure, initialise the various fields for
* startup of a new journaling session. We use this both when creating
* a journal, and after recovering an old journal to reset it for
* subsequent use.
*/
static int journal_reset(journal_t *journal)
{
journal_superblock_t *sb = journal->j_superblock;
unsigned long long first, last;
first = be32_to_cpu(sb->s_first);
last = be32_to_cpu(sb->s_maxlen);
if (first + JBD2_MIN_JOURNAL_BLOCKS > last + 1) {
printk(KERN_ERR "JBD2: Journal too short (blocks %llu-%llu).\n",
first, last);
journal_fail_superblock(journal);
return -EINVAL;
}
journal->j_first = first;
journal->j_last = last;
journal->j_head = first;
journal->j_tail = first;
journal->j_free = last - first;
journal->j_tail_sequence = journal->j_transaction_sequence;
journal->j_commit_sequence = journal->j_transaction_sequence - 1;
journal->j_commit_request = journal->j_commit_sequence;
journal->j_max_transaction_buffers = journal->j_maxlen / 4;
/*
* As a special case, if the on-disk copy is already marked as needing
* no recovery (s_start == 0), then we can safely defer the superblock
* update until the next commit by setting JBD2_FLUSHED. This avoids
* attempting a write to a potential-readonly device.
*/
if (sb->s_start == 0) {
jbd_debug(1, "JBD2: Skipping superblock update on recovered sb "
"(start %ld, seq %d, errno %d)\n",
journal->j_tail, journal->j_tail_sequence,
journal->j_errno);
journal->j_flags |= JBD2_FLUSHED;
} else {
/* Lock here to make assertions happy... */
mutex_lock(&journal->j_checkpoint_mutex);
/*
* Update log tail information. We use WRITE_FUA since new
* transaction will start reusing journal space and so we
* must make sure information about current log tail is on
* disk before that.
*/
jbd2_journal_update_sb_log_tail(journal,
journal->j_tail_sequence,
journal->j_tail,
WRITE_FUA);
mutex_unlock(&journal->j_checkpoint_mutex);
}
return jbd2_journal_start_thread(journal);
}
static void jbd2_write_superblock(journal_t *journal, int write_op)
{
struct buffer_head *bh = journal->j_sb_buffer;
int ret;
trace_jbd2_write_superblock(journal, write_op);
if (!(journal->j_flags & JBD2_BARRIER))
write_op &= ~(REQ_FUA | REQ_FLUSH);
lock_buffer(bh);
if (buffer_write_io_error(bh)) {
/*
* Oh, dear. A previous attempt to write the journal
* superblock failed. This could happen because the
* USB device was yanked out. Or it could happen to
* be a transient write error and maybe the block will
* be remapped. Nothing we can do but to retry the
* write and hope for the best.
*/
printk(KERN_ERR "JBD2: previous I/O error detected "
"for journal superblock update for %s.\n",
journal->j_devname);
clear_buffer_write_io_error(bh);
set_buffer_uptodate(bh);
}
get_bh(bh);
bh->b_end_io = end_buffer_write_sync;
ret = submit_bh(write_op, bh);
wait_on_buffer(bh);
if (buffer_write_io_error(bh)) {
clear_buffer_write_io_error(bh);
set_buffer_uptodate(bh);
ret = -EIO;
}
if (ret) {
printk(KERN_ERR "JBD2: Error %d detected when updating "
"journal superblock for %s.\n", ret,
journal->j_devname);
}
}
/**
* jbd2_journal_update_sb_log_tail() - Update log tail in journal sb on disk.
* @journal: The journal to update.
* @tail_tid: TID of the new transaction at the tail of the log
* @tail_block: The first block of the transaction at the tail of the log
* @write_op: With which operation should we write the journal sb
*
* Update a journal's superblock information about log tail and write it to
* disk, waiting for the IO to complete.
*/
void jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
unsigned long tail_block, int write_op)
{
journal_superblock_t *sb = journal->j_superblock;
BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
jbd_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
tail_block, tail_tid);
sb->s_sequence = cpu_to_be32(tail_tid);
sb->s_start = cpu_to_be32(tail_block);
jbd2_write_superblock(journal, write_op);
/* Log is no longer empty */
write_lock(&journal->j_state_lock);
WARN_ON(!sb->s_sequence);
journal->j_flags &= ~JBD2_FLUSHED;
write_unlock(&journal->j_state_lock);
}
/**
* jbd2_mark_journal_empty() - Mark on disk journal as empty.
* @journal: The journal to update.
*
* Update a journal's dynamic superblock fields to show that journal is empty.
* Write updated superblock to disk waiting for IO to complete.
*/
static void jbd2_mark_journal_empty(journal_t *journal)
{
journal_superblock_t *sb = journal->j_superblock;
BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
read_lock(&journal->j_state_lock);
jbd_debug(1, "JBD2: Marking journal as empty (seq %d)\n",
journal->j_tail_sequence);
sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
sb->s_start = cpu_to_be32(0);
read_unlock(&journal->j_state_lock);
jbd2_write_superblock(journal, WRITE_FUA);
/* Log is no longer empty */
write_lock(&journal->j_state_lock);
journal->j_flags |= JBD2_FLUSHED;
write_unlock(&journal->j_state_lock);
}
/**
* jbd2_journal_update_sb_errno() - Update error in the journal.
* @journal: The journal to update.
*
* Update a journal's errno. Write updated superblock to disk waiting for IO
* to complete.
*/
void jbd2_journal_update_sb_errno(journal_t *journal)
{
journal_superblock_t *sb = journal->j_superblock;
read_lock(&journal->j_state_lock);
jbd_debug(1, "JBD2: updating superblock error (errno %d)\n",
journal->j_errno);
sb->s_errno = cpu_to_be32(journal->j_errno);
read_unlock(&journal->j_state_lock);
jbd2_write_superblock(journal, WRITE_SYNC);
}
EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
/*
* Read the superblock for a given journal, performing initial
* validation of the format.
*/
static int journal_get_superblock(journal_t *journal)
{
struct buffer_head *bh;
journal_superblock_t *sb;
int err = -EIO;
bh = journal->j_sb_buffer;
J_ASSERT(bh != NULL);
if (!buffer_uptodate(bh)) {
ll_rw_block(READ, 1, &bh);
wait_on_buffer(bh);
if (!buffer_uptodate(bh)) {
printk(KERN_ERR
"JBD2: IO error reading journal superblock\n");
goto out;
}
}
sb = journal->j_superblock;
err = -EINVAL;
if (sb->s_header.h_magic != cpu_to_be32(JBD2_MAGIC_NUMBER) ||
sb->s_blocksize != cpu_to_be32(journal->j_blocksize)) {
printk(KERN_WARNING "JBD2: no valid journal superblock found\n");
goto out;
}
switch(be32_to_cpu(sb->s_header.h_blocktype)) {
case JBD2_SUPERBLOCK_V1:
journal->j_format_version = 1;
break;
case JBD2_SUPERBLOCK_V2:
journal->j_format_version = 2;
break;
default:
printk(KERN_WARNING "JBD2: unrecognised superblock format ID\n");
goto out;
}
if (be32_to_cpu(sb->s_maxlen) < journal->j_maxlen)
journal->j_maxlen = be32_to_cpu(sb->s_maxlen);
else if (be32_to_cpu(sb->s_maxlen) > journal->j_maxlen) {
printk(KERN_WARNING "JBD2: journal file too short\n");
goto out;
}
if (be32_to_cpu(sb->s_first) == 0 ||
be32_to_cpu(sb->s_first) >= journal->j_maxlen) {
printk(KERN_WARNING
"JBD2: Invalid start block of journal: %u\n",
be32_to_cpu(sb->s_first));
goto out;
}
return 0;
out:
journal_fail_superblock(journal);
return err;
}
/*
* Load the on-disk journal superblock and read the key fields into the
* journal_t.
*/
static int load_superblock(journal_t *journal)
{
int err;
journal_superblock_t *sb;
err = journal_get_superblock(journal);
if (err)
return err;
sb = journal->j_superblock;
journal->j_tail_sequence = be32_to_cpu(sb->s_sequence);
journal->j_tail = be32_to_cpu(sb->s_start);
journal->j_first = be32_to_cpu(sb->s_first);
journal->j_last = be32_to_cpu(sb->s_maxlen);
journal->j_errno = be32_to_cpu(sb->s_errno);
return 0;
}
/**
* int jbd2_journal_load() - Read journal from disk.
* @journal: Journal to act on.
*
* Given a journal_t structure which tells us which disk blocks contain
* a journal, read the journal from disk to initialise the in-memory
* structures.
*/
int jbd2_journal_load(journal_t *journal)
{
int err;
journal_superblock_t *sb;
err = load_superblock(journal);
if (err)
return err;
sb = journal->j_superblock;
/* If this is a V2 superblock, then we have to check the
* features flags on it. */
if (journal->j_format_version >= 2) {
if ((sb->s_feature_ro_compat &
~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) ||
(sb->s_feature_incompat &
~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) {
printk(KERN_WARNING
"JBD2: Unrecognised features on journal\n");
return -EINVAL;
}
}
/*
* Create a slab for this blocksize
*/
err = jbd2_journal_create_slab(be32_to_cpu(sb->s_blocksize));
if (err)
return err;
/* Let the recovery code check whether it needs to recover any
* data from the journal. */
if (jbd2_journal_recover(journal))
goto recovery_error;
if (journal->j_failed_commit) {
printk(KERN_ERR "JBD2: journal transaction %u on %s "
"is corrupt.\n", journal->j_failed_commit,
journal->j_devname);
return -EIO;
}
/* OK, we've finished with the dynamic journal bits:
* reinitialise the dynamic contents of the superblock in memory
* and reset them on disk. */
if (journal_reset(journal))
goto recovery_error;
journal->j_flags &= ~JBD2_ABORT;
journal->j_flags |= JBD2_LOADED;
return 0;
recovery_error:
printk(KERN_WARNING "JBD2: recovery failed\n");
return -EIO;
}
/**
* void jbd2_journal_destroy() - Release a journal_t structure.
* @journal: Journal to act on.
*
* Release a journal_t structure once it is no longer in use by the
* journaled object.
* Return <0 if we couldn't clean up the journal.
*/
int jbd2_journal_destroy(journal_t *journal)
{
int err = 0;
/* Wait for the commit thread to wake up and die. */
journal_kill_thread(journal);
/* Force a final log commit */
if (journal->j_running_transaction)
jbd2_journal_commit_transaction(journal);
/* Force any old transactions to disk */
/* Totally anal locking here... */
spin_lock(&journal->j_list_lock);
while (journal->j_checkpoint_transactions != NULL) {
spin_unlock(&journal->j_list_lock);
mutex_lock(&journal->j_checkpoint_mutex);
jbd2_log_do_checkpoint(journal);
mutex_unlock(&journal->j_checkpoint_mutex);
spin_lock(&journal->j_list_lock);
}
J_ASSERT(journal->j_running_transaction == NULL);
J_ASSERT(journal->j_committing_transaction == NULL);
J_ASSERT(journal->j_checkpoint_transactions == NULL);
spin_unlock(&journal->j_list_lock);
if (journal->j_sb_buffer) {
if (!is_journal_aborted(journal)) {
mutex_lock(&journal->j_checkpoint_mutex);
jbd2_mark_journal_empty(journal);
mutex_unlock(&journal->j_checkpoint_mutex);
} else
err = -EIO;
brelse(journal->j_sb_buffer);
}
if (journal->j_proc_entry)
jbd2_stats_proc_exit(journal);
if (journal->j_inode)
iput(journal->j_inode);
if (journal->j_revoke)
jbd2_journal_destroy_revoke(journal);
kfree(journal->j_wbuf);
kfree(journal);
return err;
}
/**
*int jbd2_journal_check_used_features () - Check if features specified are used.
* @journal: Journal to check.
* @compat: bitmask of compatible features
* @ro: bitmask of features that force read-only mount
* @incompat: bitmask of incompatible features
*
* Check whether the journal uses all of a given set of
* features. Return true (non-zero) if it does.
**/
int jbd2_journal_check_used_features (journal_t *journal, unsigned long compat,
unsigned long ro, unsigned long incompat)
{
journal_superblock_t *sb;
if (!compat && !ro && !incompat)
return 1;
/* Load journal superblock if it is not loaded yet. */
if (journal->j_format_version == 0 &&
journal_get_superblock(journal) != 0)
return 0;
if (journal->j_format_version == 1)
return 0;
sb = journal->j_superblock;
if (((be32_to_cpu(sb->s_feature_compat) & compat) == compat) &&
((be32_to_cpu(sb->s_feature_ro_compat) & ro) == ro) &&
((be32_to_cpu(sb->s_feature_incompat) & incompat) == incompat))
return 1;
return 0;
}
/**
* int jbd2_journal_check_available_features() - Check feature set in journalling layer
* @journal: Journal to check.
* @compat: bitmask of compatible features
* @ro: bitmask of features that force read-only mount
* @incompat: bitmask of incompatible features
*
* Check whether the journaling code supports the use of
* all of a given set of features on this journal. Return true
* (non-zero) if it can. */
int jbd2_journal_check_available_features (journal_t *journal, unsigned long compat,
unsigned long ro, unsigned long incompat)
{
if (!compat && !ro && !incompat)
return 1;
/* We can support any known requested features iff the
* superblock is in version 2. Otherwise we fail to support any
* extended sb features. */
if (journal->j_format_version != 2)
return 0;
if ((compat & JBD2_KNOWN_COMPAT_FEATURES) == compat &&
(ro & JBD2_KNOWN_ROCOMPAT_FEATURES) == ro &&
(incompat & JBD2_KNOWN_INCOMPAT_FEATURES) == incompat)
return 1;
return 0;
}
/**
* int jbd2_journal_set_features () - Mark a given journal feature in the superblock
* @journal: Journal to act on.
* @compat: bitmask of compatible features
* @ro: bitmask of features that force read-only mount
* @incompat: bitmask of incompatible features
*
* Mark a given journal feature as present on the
* superblock. Returns true if the requested features could be set.
*
*/
int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
unsigned long ro, unsigned long incompat)
{
journal_superblock_t *sb;
if (jbd2_journal_check_used_features(journal, compat, ro, incompat))
return 1;
if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
return 0;
jbd_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n",
compat, ro, incompat);
sb = journal->j_superblock;
sb->s_feature_compat |= cpu_to_be32(compat);
sb->s_feature_ro_compat |= cpu_to_be32(ro);
sb->s_feature_incompat |= cpu_to_be32(incompat);
return 1;
}
/*
* jbd2_journal_clear_features () - Clear a given journal feature in the
* superblock
* @journal: Journal to act on.
* @compat: bitmask of compatible features
* @ro: bitmask of features that force read-only mount
* @incompat: bitmask of incompatible features
*
* Clear a given journal feature as present on the
* superblock.
*/
void jbd2_journal_clear_features(journal_t *journal, unsigned long compat,
unsigned long ro, unsigned long incompat)
{
journal_superblock_t *sb;
jbd_debug(1, "Clear features 0x%lx/0x%lx/0x%lx\n",
compat, ro, incompat);
sb = journal->j_superblock;
sb->s_feature_compat &= ~cpu_to_be32(compat);
sb->s_feature_ro_compat &= ~cpu_to_be32(ro);
sb->s_feature_incompat &= ~cpu_to_be32(incompat);
}
EXPORT_SYMBOL(jbd2_journal_clear_features);
/**
* int jbd2_journal_flush () - Flush journal
* @journal: Journal to act on.
*
* Flush all data for a given journal to disk and empty the journal.
* Filesystems can use this when remounting readonly to ensure that
* recovery does not need to happen on remount.
*/
int jbd2_journal_flush(journal_t *journal)
{
int err = 0;
transaction_t *transaction = NULL;
write_lock(&journal->j_state_lock);
/* Force everything buffered to the log... */
if (journal->j_running_transaction) {
transaction = journal->j_running_transaction;
__jbd2_log_start_commit(journal, transaction->t_tid);
} else if (journal->j_committing_transaction)
transaction = journal->j_committing_transaction;
/* Wait for the log commit to complete... */
if (transaction) {
tid_t tid = transaction->t_tid;
write_unlock(&journal->j_state_lock);
jbd2_log_wait_commit(journal, tid);
} else {
write_unlock(&journal->j_state_lock);
}
/* ...and flush everything in the log out to disk. */
spin_lock(&journal->j_list_lock);
while (!err && journal->j_checkpoint_transactions != NULL) {
spin_unlock(&journal->j_list_lock);
mutex_lock(&journal->j_checkpoint_mutex);
err = jbd2_log_do_checkpoint(journal);
mutex_unlock(&journal->j_checkpoint_mutex);
spin_lock(&journal->j_list_lock);
}
spin_unlock(&journal->j_list_lock);
if (is_journal_aborted(journal))
return -EIO;
mutex_lock(&journal->j_checkpoint_mutex);
jbd2_cleanup_journal_tail(journal);
/* Finally, mark the journal as really needing no recovery.
* This sets s_start==0 in the underlying superblock, which is
* the magic code for a fully-recovered superblock. Any future
* commits of data to the journal will restore the current
* s_start value. */
jbd2_mark_journal_empty(journal);
mutex_unlock(&journal->j_checkpoint_mutex);
write_lock(&journal->j_state_lock);
J_ASSERT(!journal->j_running_transaction);
J_ASSERT(!journal->j_committing_transaction);
J_ASSERT(!journal->j_checkpoint_transactions);
J_ASSERT(journal->j_head == journal->j_tail);
J_ASSERT(journal->j_tail_sequence == journal->j_transaction_sequence);
write_unlock(&journal->j_state_lock);
return 0;
}
/**
* int jbd2_journal_wipe() - Wipe journal contents
* @journal: Journal to act on.
* @write: flag (see below)
*
* Wipe out all of the contents of a journal, safely. This will produce
* a warning if the journal contains any valid recovery information.
* Must be called between journal_init_*() and jbd2_journal_load().
*
* If 'write' is non-zero, then we wipe out the journal on disk; otherwise
* we merely suppress recovery.
*/
int jbd2_journal_wipe(journal_t *journal, int write)
{
int err = 0;
J_ASSERT (!(journal->j_flags & JBD2_LOADED));
err = load_superblock(journal);
if (err)
return err;
if (!journal->j_tail)
goto no_recovery;
printk(KERN_WARNING "JBD2: %s recovery information on journal\n",
write ? "Clearing" : "Ignoring");
err = jbd2_journal_skip_recovery(journal);
if (write) {
/* Lock to make assertions happy... */
mutex_lock(&journal->j_checkpoint_mutex);
jbd2_mark_journal_empty(journal);
mutex_unlock(&journal->j_checkpoint_mutex);
}
no_recovery:
return err;
}
/*
* Journal abort has very specific semantics, which we describe
* for journal abort.
*
* Two internal functions, which provide abort to the jbd layer
* itself are here.
*/
/*
* Quick version for internal journal use (doesn't lock the journal).
* Aborts hard --- we mark the abort as occurred, but do _nothing_ else,
* and don't attempt to make any other journal updates.
*/
void __jbd2_journal_abort_hard(journal_t *journal)
{
transaction_t *transaction;
if (journal->j_flags & JBD2_ABORT)
return;
printk(KERN_ERR "Aborting journal on device %s.\n",
journal->j_devname);
write_lock(&journal->j_state_lock);
journal->j_flags |= JBD2_ABORT;
transaction = journal->j_running_transaction;
if (transaction)
__jbd2_log_start_commit(journal, transaction->t_tid);
write_unlock(&journal->j_state_lock);
}
/* Soft abort: record the abort error status in the journal superblock,
* but don't do any other IO. */
static void __journal_abort_soft (journal_t *journal, int errno)
{
if (journal->j_flags & JBD2_ABORT)
return;
if (!journal->j_errno)
journal->j_errno = errno;
__jbd2_journal_abort_hard(journal);
if (errno)
jbd2_journal_update_sb_errno(journal);
}
/**
* void jbd2_journal_abort () - Shutdown the journal immediately.
* @journal: the journal to shutdown.
* @errno: an error number to record in the journal indicating
* the reason for the shutdown.
*
* Perform a complete, immediate shutdown of the ENTIRE
* journal (not of a single transaction). This operation cannot be
* undone without closing and reopening the journal.
*
* The jbd2_journal_abort function is intended to support higher level error
* recovery mechanisms such as the ext2/ext3 remount-readonly error
* mode.
*
* Journal abort has very specific semantics. Any existing dirty,
* unjournaled buffers in the main filesystem will still be written to
* disk by bdflush, but the journaling mechanism will be suspended
* immediately and no further transaction commits will be honoured.
*
* Any dirty, journaled buffers will be written back to disk without
* hitting the journal. Atomicity cannot be guaranteed on an aborted
* filesystem, but we _do_ attempt to leave as much data as possible
* behind for fsck to use for cleanup.
*
* Any attempt to get a new transaction handle on a journal which is in
* ABORT state will just result in an -EROFS error return. A
* jbd2_journal_stop on an existing handle will return -EIO if we have
* entered abort state during the update.
*
* Recursive transactions are not disturbed by journal abort until the
* final jbd2_journal_stop, which will receive the -EIO error.
*
* Finally, the jbd2_journal_abort call allows the caller to supply an errno
* which will be recorded (if possible) in the journal superblock. This
* allows a client to record failure conditions in the middle of a
* transaction without having to complete the transaction to record the
* failure to disk. ext3_error, for example, now uses this
* functionality.
*
* Errors which originate from within the journaling layer will NOT
* supply an errno; a null errno implies that absolutely no further
* writes are done to the journal (unless there are any already in
* progress).
*
*/
void jbd2_journal_abort(journal_t *journal, int errno)
{
__journal_abort_soft(journal, errno);
}
/**
* int jbd2_journal_errno () - returns the journal's error state.
* @journal: journal to examine.
*
* This is the errno number set with jbd2_journal_abort(), the last
* time the journal was mounted - if the journal was stopped
* without calling abort this will be 0.
*
* If the journal has been aborted on this mount time -EROFS will
* be returned.
*/
int jbd2_journal_errno(journal_t *journal)
{
int err;
read_lock(&journal->j_state_lock);
if (journal->j_flags & JBD2_ABORT)
err = -EROFS;
else
err = journal->j_errno;
read_unlock(&journal->j_state_lock);
return err;
}
/**
* int jbd2_journal_clear_err () - clears the journal's error state
* @journal: journal to act on.
*
* An error must be cleared or acked to take a FS out of readonly
* mode.
*/
int jbd2_journal_clear_err(journal_t *journal)
{
int err = 0;
write_lock(&journal->j_state_lock);
if (journal->j_flags & JBD2_ABORT)
err = -EROFS;
else
journal->j_errno = 0;
write_unlock(&journal->j_state_lock);
return err;
}
/**
* void jbd2_journal_ack_err() - Ack journal err.
* @journal: journal to act on.
*
* An error must be cleared or acked to take a FS out of readonly
* mode.
*/
void jbd2_journal_ack_err(journal_t *journal)
{
write_lock(&journal->j_state_lock);
if (journal->j_errno)
journal->j_flags |= JBD2_ACK_ERR;
write_unlock(&journal->j_state_lock);
}
int jbd2_journal_blocks_per_page(struct inode *inode)
{
return 1 << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
}
/*
* helper functions to deal with 32 or 64bit block numbers.
*/
size_t journal_tag_bytes(journal_t *journal)
{
if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
return JBD2_TAG_SIZE64;
else
return JBD2_TAG_SIZE32;
}
/*
* JBD memory management
*
* These functions are used to allocate block-sized chunks of memory
* used for making copies of buffer_head data. Very often it will be
* page-sized chunks of data, but sometimes it will be in
* sub-page-size chunks. (For example, 16k pages on Power systems
* with a 4k block file system.) For blocks smaller than a page, we
* use a SLAB allocator. There are slab caches for each block size,
* which are allocated at mount time, if necessary, and we only free
* (all of) the slab caches when/if the jbd2 module is unloaded. For
* this reason we don't need to a mutex to protect access to
* jbd2_slab[] allocating or releasing memory; only in
* jbd2_journal_create_slab().
*/
#define JBD2_MAX_SLABS 8
static struct kmem_cache *jbd2_slab[JBD2_MAX_SLABS];
static const char *jbd2_slab_names[JBD2_MAX_SLABS] = {
"jbd2_1k", "jbd2_2k", "jbd2_4k", "jbd2_8k",
"jbd2_16k", "jbd2_32k", "jbd2_64k", "jbd2_128k"
};
static void jbd2_journal_destroy_slabs(void)
{
int i;
for (i = 0; i < JBD2_MAX_SLABS; i++) {
if (jbd2_slab[i])
kmem_cache_destroy(jbd2_slab[i]);
jbd2_slab[i] = NULL;
}
}
static int jbd2_journal_create_slab(size_t size)
{
static DEFINE_MUTEX(jbd2_slab_create_mutex);
int i = order_base_2(size) - 10;
size_t slab_size;
if (size == PAGE_SIZE)
return 0;
if (i >= JBD2_MAX_SLABS)
return -EINVAL;
if (unlikely(i < 0))
i = 0;
mutex_lock(&jbd2_slab_create_mutex);
if (jbd2_slab[i]) {
mutex_unlock(&jbd2_slab_create_mutex);
return 0; /* Already created */
}
slab_size = 1 << (i+10);
jbd2_slab[i] = kmem_cache_create(jbd2_slab_names[i], slab_size,
slab_size, 0, NULL);
mutex_unlock(&jbd2_slab_create_mutex);
if (!jbd2_slab[i]) {
printk(KERN_EMERG "JBD2: no memory for jbd2_slab cache\n");
return -ENOMEM;
}
return 0;
}
static struct kmem_cache *get_slab(size_t size)
{
int i = order_base_2(size) - 10;
BUG_ON(i >= JBD2_MAX_SLABS);
if (unlikely(i < 0))
i = 0;
BUG_ON(jbd2_slab[i] == NULL);
return jbd2_slab[i];
}
void *jbd2_alloc(size_t size, gfp_t flags)
{
void *ptr;
BUG_ON(size & (size-1)); /* Must be a power of 2 */
flags |= __GFP_REPEAT;
if (size == PAGE_SIZE)
ptr = (void *)__get_free_pages(flags, 0);
else if (size > PAGE_SIZE) {
int order = get_order(size);
if (order < 3)
ptr = (void *)__get_free_pages(flags, order);
else
ptr = vmalloc(size);
} else
ptr = kmem_cache_alloc(get_slab(size), flags);
/* Check alignment; SLUB has gotten this wrong in the past,
* and this can lead to user data corruption! */
BUG_ON(((unsigned long) ptr) & (size-1));
return ptr;
}
void jbd2_free(void *ptr, size_t size)
{
if (size == PAGE_SIZE) {
free_pages((unsigned long)ptr, 0);
return;
}
if (size > PAGE_SIZE) {
int order = get_order(size);
if (order < 3)
free_pages((unsigned long)ptr, order);
else
vfree(ptr);
return;
}
kmem_cache_free(get_slab(size), ptr);
};
/*
* Journal_head storage management
*/
static struct kmem_cache *jbd2_journal_head_cache;
#ifdef CONFIG_JBD2_DEBUG
static atomic_t nr_journal_heads = ATOMIC_INIT(0);
#endif
static int jbd2_journal_init_journal_head_cache(void)
{
int retval;
J_ASSERT(jbd2_journal_head_cache == NULL);
jbd2_journal_head_cache = kmem_cache_create("jbd2_journal_head",
sizeof(struct journal_head),
0, /* offset */
SLAB_TEMPORARY, /* flags */
NULL); /* ctor */
retval = 0;
if (!jbd2_journal_head_cache) {
retval = -ENOMEM;
printk(KERN_EMERG "JBD2: no memory for journal_head cache\n");
}
return retval;
}
static void jbd2_journal_destroy_journal_head_cache(void)
{
if (jbd2_journal_head_cache) {
kmem_cache_destroy(jbd2_journal_head_cache);
jbd2_journal_head_cache = NULL;
}
}
/*
* journal_head splicing and dicing
*/
static struct journal_head *journal_alloc_journal_head(void)
{
struct journal_head *ret;
#ifdef CONFIG_JBD2_DEBUG
atomic_inc(&nr_journal_heads);
#endif
ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
if (!ret) {
jbd_debug(1, "out of memory for journal_head\n");
pr_notice_ratelimited("ENOMEM in %s, retrying.\n", __func__);
while (!ret) {
yield();
ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
}
}
return ret;
}
static void journal_free_journal_head(struct journal_head *jh)
{
#ifdef CONFIG_JBD2_DEBUG
atomic_dec(&nr_journal_heads);
memset(jh, JBD2_POISON_FREE, sizeof(*jh));
#endif
kmem_cache_free(jbd2_journal_head_cache, jh);
}
/*
* A journal_head is attached to a buffer_head whenever JBD has an
* interest in the buffer.
*
* Whenever a buffer has an attached journal_head, its ->b_state:BH_JBD bit
* is set. This bit is tested in core kernel code where we need to take
* JBD-specific actions. Testing the zeroness of ->b_private is not reliable
* there.
*
* When a buffer has its BH_JBD bit set, its ->b_count is elevated by one.
*
* When a buffer has its BH_JBD bit set it is immune from being released by
* core kernel code, mainly via ->b_count.
*
* A journal_head is detached from its buffer_head when the journal_head's
* b_jcount reaches zero. Running transaction (b_transaction) and checkpoint
* transaction (b_cp_transaction) hold their references to b_jcount.
*
* Various places in the kernel want to attach a journal_head to a buffer_head
* _before_ attaching the journal_head to a transaction. To protect the
* journal_head in this situation, jbd2_journal_add_journal_head elevates the
* journal_head's b_jcount refcount by one. The caller must call
* jbd2_journal_put_journal_head() to undo this.
*
* So the typical usage would be:
*
* (Attach a journal_head if needed. Increments b_jcount)
* struct journal_head *jh = jbd2_journal_add_journal_head(bh);
* ...
* (Get another reference for transaction)
* jbd2_journal_grab_journal_head(bh);
* jh->b_transaction = xxx;
* (Put original reference)
* jbd2_journal_put_journal_head(jh);
*/
/*
* Give a buffer_head a journal_head.
*
* May sleep.
*/
struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
{
struct journal_head *jh;
struct journal_head *new_jh = NULL;
repeat:
if (!buffer_jbd(bh)) {
new_jh = journal_alloc_journal_head();
memset(new_jh, 0, sizeof(*new_jh));
}
jbd_lock_bh_journal_head(bh);
if (buffer_jbd(bh)) {
jh = bh2jh(bh);
} else {
J_ASSERT_BH(bh,
(atomic_read(&bh->b_count) > 0) ||
(bh->b_page && bh->b_page->mapping));
if (!new_jh) {
jbd_unlock_bh_journal_head(bh);
goto repeat;
}
jh = new_jh;
new_jh = NULL; /* We consumed it */
set_buffer_jbd(bh);
bh->b_private = jh;
jh->b_bh = bh;
get_bh(bh);
BUFFER_TRACE(bh, "added journal_head");
}
jh->b_jcount++;
jbd_unlock_bh_journal_head(bh);
if (new_jh)
journal_free_journal_head(new_jh);
return bh->b_private;
}
/*
* Grab a ref against this buffer_head's journal_head. If it ended up not
* having a journal_head, return NULL
*/
struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh)
{
struct journal_head *jh = NULL;
jbd_lock_bh_journal_head(bh);
if (buffer_jbd(bh)) {
jh = bh2jh(bh);
jh->b_jcount++;
}
jbd_unlock_bh_journal_head(bh);
return jh;
}
static void __journal_remove_journal_head(struct buffer_head *bh)
{
struct journal_head *jh = bh2jh(bh);
J_ASSERT_JH(jh, jh->b_jcount >= 0);
J_ASSERT_JH(jh, jh->b_transaction == NULL);
J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
J_ASSERT_JH(jh, jh->b_cp_transaction == NULL);
J_ASSERT_JH(jh, jh->b_jlist == BJ_None);
J_ASSERT_BH(bh, buffer_jbd(bh));
J_ASSERT_BH(bh, jh2bh(jh) == bh);
BUFFER_TRACE(bh, "remove journal_head");
if (jh->b_frozen_data) {
printk(KERN_WARNING "%s: freeing b_frozen_data\n", __func__);
jbd2_free(jh->b_frozen_data, bh->b_size);
}
if (jh->b_committed_data) {
printk(KERN_WARNING "%s: freeing b_committed_data\n", __func__);
jbd2_free(jh->b_committed_data, bh->b_size);
}
bh->b_private = NULL;
jh->b_bh = NULL; /* debug, really */
clear_buffer_jbd(bh);
journal_free_journal_head(jh);
}
/*
* Drop a reference on the passed journal_head. If it fell to zero then
* release the journal_head from the buffer_head.
*/
void jbd2_journal_put_journal_head(struct journal_head *jh)
{
struct buffer_head *bh = jh2bh(jh);
jbd_lock_bh_journal_head(bh);
J_ASSERT_JH(jh, jh->b_jcount > 0);
--jh->b_jcount;
if (!jh->b_jcount) {
__journal_remove_journal_head(bh);
jbd_unlock_bh_journal_head(bh);
__brelse(bh);
} else
jbd_unlock_bh_journal_head(bh);
}
/*
* Initialize jbd inode head
*/
void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode)
{
jinode->i_transaction = NULL;
jinode->i_next_transaction = NULL;
jinode->i_vfs_inode = inode;
jinode->i_flags = 0;
INIT_LIST_HEAD(&jinode->i_list);
}
/*
* Function to be called before we start removing inode from memory (i.e.,
* clear_inode() is a fine place to be called from). It removes inode from
* transaction's lists.
*/
void jbd2_journal_release_jbd_inode(journal_t *journal,
struct jbd2_inode *jinode)
{
if (!journal)
return;
restart:
spin_lock(&journal->j_list_lock);
/* Is commit writing out inode - we have to wait */
if (test_bit(__JI_COMMIT_RUNNING, &jinode->i_flags)) {
wait_queue_head_t *wq;
DEFINE_WAIT_BIT(wait, &jinode->i_flags, __JI_COMMIT_RUNNING);
wq = bit_waitqueue(&jinode->i_flags, __JI_COMMIT_RUNNING);
prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
spin_unlock(&journal->j_list_lock);
schedule();
finish_wait(wq, &wait.wait);
goto restart;
}
if (jinode->i_transaction) {
list_del(&jinode->i_list);
jinode->i_transaction = NULL;
}
spin_unlock(&journal->j_list_lock);
}
/*
* debugfs tunables
*/
#ifdef CONFIG_JBD2_DEBUG
u8 jbd2_journal_enable_debug __read_mostly;
EXPORT_SYMBOL(jbd2_journal_enable_debug);
#define JBD2_DEBUG_NAME "jbd2-debug"
static struct dentry *jbd2_debugfs_dir;
static struct dentry *jbd2_debug;
static void __init jbd2_create_debugfs_entry(void)
{
jbd2_debugfs_dir = debugfs_create_dir("jbd2", NULL);
if (jbd2_debugfs_dir)
jbd2_debug = debugfs_create_u8(JBD2_DEBUG_NAME,
S_IRUGO | S_IWUSR,
jbd2_debugfs_dir,
&jbd2_journal_enable_debug);
}
static void __exit jbd2_remove_debugfs_entry(void)
{
debugfs_remove(jbd2_debug);
debugfs_remove(jbd2_debugfs_dir);
}
#else
static void __init jbd2_create_debugfs_entry(void)
{
}
static void __exit jbd2_remove_debugfs_entry(void)
{
}
#endif
#ifdef CONFIG_PROC_FS
#define JBD2_STATS_PROC_NAME "fs/jbd2"
static void __init jbd2_create_jbd_stats_proc_entry(void)
{
proc_jbd2_stats = proc_mkdir(JBD2_STATS_PROC_NAME, NULL);
}
static void __exit jbd2_remove_jbd_stats_proc_entry(void)
{
if (proc_jbd2_stats)
remove_proc_entry(JBD2_STATS_PROC_NAME, NULL);
}
#else
#define jbd2_create_jbd_stats_proc_entry() do {} while (0)
#define jbd2_remove_jbd_stats_proc_entry() do {} while (0)
#endif
struct kmem_cache *jbd2_handle_cache, *jbd2_inode_cache;
static int __init jbd2_journal_init_handle_cache(void)
{
jbd2_handle_cache = KMEM_CACHE(jbd2_journal_handle, SLAB_TEMPORARY);
if (jbd2_handle_cache == NULL) {
printk(KERN_EMERG "JBD2: failed to create handle cache\n");
return -ENOMEM;
}
jbd2_inode_cache = KMEM_CACHE(jbd2_inode, 0);
if (jbd2_inode_cache == NULL) {
printk(KERN_EMERG "JBD2: failed to create inode cache\n");
kmem_cache_destroy(jbd2_handle_cache);
return -ENOMEM;
}
return 0;
}
static void jbd2_journal_destroy_handle_cache(void)
{
if (jbd2_handle_cache)
kmem_cache_destroy(jbd2_handle_cache);
if (jbd2_inode_cache)
kmem_cache_destroy(jbd2_inode_cache);
}
/*
* Module startup and shutdown
*/
static int __init journal_init_caches(void)
{
int ret;
ret = jbd2_journal_init_revoke_caches();
if (ret == 0)
ret = jbd2_journal_init_journal_head_cache();
if (ret == 0)
ret = jbd2_journal_init_handle_cache();
if (ret == 0)
ret = jbd2_journal_init_transaction_cache();
return ret;
}
static void jbd2_journal_destroy_caches(void)
{
jbd2_journal_destroy_revoke_caches();
jbd2_journal_destroy_journal_head_cache();
jbd2_journal_destroy_handle_cache();
jbd2_journal_destroy_transaction_cache();
jbd2_journal_destroy_slabs();
}
static int __init journal_init(void)
{
int ret;
BUILD_BUG_ON(sizeof(struct journal_superblock_s) != 1024);
ret = journal_init_caches();
if (ret == 0) {
jbd2_create_debugfs_entry();
jbd2_create_jbd_stats_proc_entry();
} else {
jbd2_journal_destroy_caches();
}
return ret;
}
static void __exit journal_exit(void)
{
#ifdef CONFIG_JBD2_DEBUG
int n = atomic_read(&nr_journal_heads);
if (n)
printk(KERN_EMERG "JBD2: leaked %d journal_heads!\n", n);
#endif
jbd2_remove_debugfs_entry();
jbd2_remove_jbd_stats_proc_entry();
jbd2_journal_destroy_caches();
}
MODULE_LICENSE("GPL");
module_init(journal_init);
module_exit(journal_exit);
|
Slayjay78/android_kernel_lge_hammerhead
|
fs/jbd2/journal.c
|
C
|
gpl-2.0
| 71,335 |
<?php
class ESSBMetaboxOptionsFramework {
public static $color_fields = array();
public static $was_lastrow_even = false;
public static $section_active = false;
public static function reset_row_status() {
self::$was_lastrow_even = false;
}
public static function draw_options_field($option) {
global $essb_admin_options, $essb_admin_options_fanscounter;
$type = $option['type'];
$title = isset($option['title']) ? $option['title'] : '';
$submenu_link = isset($option['submenu_link']) ? $option['submenu_link'] : "";
$description = isset($option['description']) ? $option['description'] : "";
$id = isset($option['id']) ? $option['id'] : '';
$icon = isset($option['icon']) ? $option['icon'] : '';
$icon_position = isset($option['icon_position']) ? $option['icon_position'] : '';
$on_text = isset($option['on_label']) ? $option['on_label'] : "";
$off_text = isset($option['off_label']) ? $option['off_label'] : "";
$listOfValues = isset($option['values']) ? $option['values'] : array();
$class = isset($option['class']) ? $option['class'] : '';
$mode = isset($option['mode']) ? $option['mode'] : 'htmlmixed';
$recommended = isset($option['recommended']) ? $option['recommended'] : '';
$select2_options = isset($option['select2_options']) ? $option['select2_options'] : array();
$settings_group = "essb_metabox";
$option_value = isset($essb_admin_options[$id]) ? $essb_admin_options[$id] : '';
switch ($type) {
case "heading1":
self::draw_heading($title, '1', $submenu_link);
break;
case "heading2":
self::draw_heading($title, '2', $submenu_link);
break;
case "heading3":
self::draw_heading($title, '3', $submenu_link);
break;
case "switch":
self::draw_options_row_start($title, $description, $recommended);
self::draw_switch_field($id, $settings_group, $option_value, $on_text, $off_text);
self::draw_options_row_end();
break;
case "text":
self::draw_options_row_start($title, $description, $recommended);
self::draw_input_field($id, false, $settings_group, $option_value, $icon, $class, $icon_position);
self::draw_options_row_end();
break;
case "text-stretched":
self::draw_options_row_start($title, $description, $recommended);
self::draw_input_field($id, true, $settings_group, $option_value, $icon, $class, $icon_position);
self::draw_options_row_end();
break;
case "checkbox":
self::draw_options_row_start($title, $description, $recommended);
self::draw_checkbox_field($id, $settings_group, $option_value);
self::draw_options_row_end();
break;
case "checkbox_list":
self::draw_options_row_start($title, $description, $recommended);
self::draw_checkbox_list_field($id, $listOfValues, $settings_group, $option_value);
self::draw_options_row_end();
break;
case "checkbox_list_sortable":
$ordered_values = isset($essb_admin_options[$id.'_order']) ? $essb_admin_options[$id.'_order'] : array();
//print_r($ordered_values);
if (is_array($ordered_values)) {
if (count($ordered_values) > 0) {
$listOfValues = $ordered_values;
$listOfValues = self::translate_key_array($listOfValues);
}
}
self::draw_options_row_start($title, $description, $recommended);
self::draw_checkbox_list_sortable_field($id, $listOfValues, $settings_group, $option_value);
self::draw_options_row_end();
break;
case "select":
self::draw_options_row_start($title, $description, $recommended);
self::draw_select_field($id, $listOfValues, false, $settings_group, $option_value);
self::draw_options_row_end();
break;
case "textarea":
self::draw_options_row_start($title, $description, $recommended);
self::draw_textarea_field($id, $settings_group, $option_value);
self::draw_options_row_end();
break;
case "editor":
self::draw_options_row_start($title, $description, $recommended);
self::draw_editor_field($id, $settings_group, $option_value, $mode);
self::draw_options_row_end();
break;
case "wpeditor":
self::draw_options_row_start($title, $description, $recommended);
self::draw_wpeditor_field($id, $settings_group, $option_value);
self::draw_options_row_end();
break;
case "color":
self::draw_options_row_start($title, $description, $recommended);
self::draw_color_field($id, $settings_group, $option_value);
self::draw_options_row_end();
break;
case "image_checkbox":
self::draw_options_row_start($title, $description, $recommended);
self::draw_image_checkbox_field($id, $listOfValues, $settings_group, $option_value);
//self::draw_image_checkbox_field($id, $listOfValues, 'essb_options', array("checkbox_option2" => true));
self::draw_options_row_end();
break;
case "image_radio":
self::draw_options_row_start($title, $description, $recommended);
self::draw_image_radio_field($id, $listOfValues, $settings_group, $option_value);
//self::draw_image_radio_field($id, $listOfValues, 'essb_options', 'checkbox_option1');
self::draw_options_row_end();
break;
case "func":
self::draw_options_row_start($title, $description, $recommended);
if (function_exists($id)) {
$id($option);
}
self::draw_options_row_end();
break;
case "file":
self::draw_options_row_start($title, $description, $recommended);
self::draw_fileselect_field($id, $settings_group, $option_value, $icon, $class);
self::draw_options_row_end();
break;
case "simplesort":
self::draw_options_row_start($title, $description, $recommended);
self::draw_simplesort_field($id, $listOfValues, $settings_group, $option_value);
self::draw_options_row_end();
break;
case 'section_start':
self::draw_options_row_start($title, $description, $recommended);
self::draw_section_start();
self::$section_active = true;
break;
case 'section_end':
self::draw_section_end();
self::draw_options_row_end();
self::$section_active = false;
break;
case "select2":
self::draw_options_row_start($title, $description, $recommended);
self::draw_select2_field($id, $listOfValues, false, $settings_group, $option_value, $select2_options);
self::draw_options_row_end();
break;
}
}
public static function draw_options_row_start($title, $description = '', $recommended = '', $colspan = '', $rowborder = true) {
$row_class = "";
if (!self::$section_active) {
$row_class = (self::$was_lastrow_even) ? "odd" : "even";
self::$was_lastrow_even = !self::$was_lastrow_even;
}
if ($description != '') {
$new_line = "<br/>";
if ($recommended != '') { $new_line = ''; }
$description = sprintf('%2$s<span class="label">%1$s', $description, $new_line);
}
if ($recommended != '') {
$recommended = '<br />
<div class="essb-recommended">
<i class="fa fa-check"></i><span></span>
</div>';
}
if ($colspan != '') {
$colspan = 'colspan="'.$colspan.'"';
}
$row_border_class = ($rowborder) ? "table-border-bottom" : '';
printf('<tr class="%1$s %2$s">', $row_class, $row_border_class);
if ($colspan != '') {
printf('<td class="bold" valign="top" %4$s>%1$s%3$s%2$s', $title, $description, $recommended, $colspan);
}
else {
printf('<td class="bold" valign="top" %4$s>%1$s%3$s%2$s</td>', $title, $description, $recommended, $colspan);
echo '<td valign="top">';
}
}
public static function draw_options_row_end() {
echo '</td>';
echo '</tr>';
}
public static function draw_section_start() {
echo '<table border="0" cellpadding="5" cellspacing="0" width="100%">
<col width="35%" />
<col width="65%" />';
}
public static function draw_section_end() {
echo '</table>';
}
public static function draw_heading($title, $level = '1', $submenu_link = '') {
$css_class_heading = "";
//print $title.'|'.$level.'|'.$submenu_link;
switch ($level) {
case "1":
$css_class_heading = "sub";
break;
case "2":
$css_class_heading = "sub2";
break;
case "3":
$css_class_heading = "sub3";
break;
default:
$css_class_heading = "sub";
break;
}
if ($submenu_link != '') {
$submenu_link = sprintf('id="essb-submenu-%1%s"', $submenu_link);
}
echo '<tr class="table-border-bottom">';
printf('<td colspan="2" class="%1$s" %2$s>%3$s</td>', $css_class_heading, $submenu_link, $title);
echo '</tr>';
}
public static function draw_simplesort_field($field, $listOfValues, $settings_group = 'essb_options', $value = '') {
if ($value == '') {
$value = $listOfValues; // initialize default values
}
printf('<ul class="essb_sortable" id="essb-sortable-%1$s">', $field);
foreach ($value as $single) {
printf('<li>%1$s<input type="hidden" name="%2$s[%3$s][]" value="%1$s"/></li>', $single, $settings_group, $field);
}
echo '</ul>';
}
public static function draw_image_checkbox_field($field, $listOfValues, $settings_group = 'essb_options', $value = '') {
$exist_user_value = false;
if ($value != '') {
$exist_user_value = true;
}
echo '<div class="essb_image_checkbox_container essb_image_checkbox_container_'.$field.'">';
foreach ( $listOfValues as $singleValueCode => $singleValue ) {
$label = isset($singleValue['label']) ? $singleValue['label'] : '';
$active_state = "";
$active_element = "";
if ($exist_user_value) {
$key = $singleValueCode;
if (in_array($key, $value)) {
$active_state = " active";
$active_element = ' checked="checked"';
}
}
if ($label != '') {
$label = sprintf('<div class="essb_checkbox_label">%1$s</div>', $label);
}
printf('<div class="essb_checkbox"><div class="essb_image_checkbox%6$s" data-field="%8$s_%3$s">
<span class="checkbox-image"><img src="%1$s/%2$s"/></span>
<span class="checkbox-state"><i class="fa fa-lg fa-check-circle"></i></span>
<input type="checkbox" id="essb_options_%8$s_%3$s" name="%4$s[%8$s][]" value="%3$s"%7$s/>
</div>%5$s</div>', ESSB3_PLUGIN_URL, $singleValue['image'], $singleValueCode, $settings_group, $label, $active_state, $active_element, $field);
}
echo '</div>';
}
public static function draw_image_radio_field($field, $listOfValues, $settings_group = 'essb_options', $value = '') {
$exist_user_value = false;
if ($value != '') {
$exist_user_value = true;
}
echo '<div class="essb_image_radio_container essb_image_radio_container_'.$field.'">';
$position = 1;
foreach ( $listOfValues as $singleValueCode => $singleValue ) {
$label = isset($singleValue['label']) ? $singleValue['label'] : '';
$active_state = "";
$active_element = "";
if ($exist_user_value) {
if ($value == $singleValueCode) {
$active_state = " active";
$active_element = ' checked="checked"';
}
}
if ($label != '') {
$label = sprintf('<div class="essb_radio_label">%1$s</div>', $label);
}
printf('<div class="essb_radio"><div class="essb_image_radio%8$s" data-field="%6$s_%7$s">
<span class="checkbox-image"><img src="%1$s/%2$s"/></span>
<span class="checkbox-state"><i class="fa fa-lg fa-check-circle"></i></span>
<input type="radio" id="essb_options_%6$s_%7$s" name="%4$s[%6$s]" value="%3$s"%9$s/>
</div>%5$s</div>', ESSB3_PLUGIN_URL, $singleValue['image'], $singleValueCode, $settings_group, $label, $field, $position, $active_state, $active_element);
$position++;
}
echo '</div>';
}
public static function draw_textarea_field($field, $settings_group = 'essb_options', $value = '') {
$value = esc_textarea ( stripslashes($value));
printf('<textarea id="essb_options_%1$s" name="%2$s[%1$s]" class="input-element stretched" rows="5">%3$s</textarea>', $field, $settings_group, $value);
}
public static function draw_wpeditor_field($field, $settings_group = 'essb_options', $value = '') {
$value = ( stripslashes($value));
//printf('<div id="wpeditor_%1$s"></div>', $field);
printf('<textarea id="essb_options_%1$s" name="%2$s[%1$s]" class="input-element stretched essb-hidden-element" rows="5">%3$s</textarea>', $field, $settings_group, $value);
$editor_options = array('textarea_name' => $settings_group.'['.$field.']');
wp_editor($value, sprintf('wpeditor_%1$s', $field), $editor_options);
}
public static function draw_editor_field($field, $settings_group = 'essb_options', $value = '', $mode = 'htmlmixed') {
$value = esc_textarea ( stripslashes($value));
printf('<textarea id="essb_options_%1$s" name="%2$s[%1$s]" class="input-element stretched is-code-editor" rows="5" data-function-activate="activate__%1$s">%3$s</textarea>', $field, $settings_group, $value);
printf('<script>
function activate__%1$s() {
console.log("actiting %1$s");
var editor_%1$s = CodeMirror.fromTextArea(document.getElementById("essb_options_%1$s"), {
lineNumbers: true,
mode: "%2$s",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
});
};
</script>', $field, $mode);
/*printf('<script>
function activate__%1$s() {
console.log("activating %1$s");
var editor_%1$s = CodeMirror.fromTextArea(document.getElementById("essb_options_%1$s"), {
lineNumbers: true,
mode: "%2$s",
lineWrapping: true,
matchBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
});
};
</script>', $field, $mode);*/
}
public static function draw_switch_field($field, $settings_group = 'essb_options', $value = '', $on_text = '', $off_text = '') {
if ($settings_group == '') { $settings_group = "essb_options"; }
if ($on_text == "") { $on_text = __('On', ESSB3_TEXT_DOMAIN); }
if ($off_text == "") { $off_text = __('Off', ESSB3_TEXT_DOMAIN); }
if ($value == "true") {
$on_switch = " selected";
$off_switch = "";
}
else {
$off_switch = " selected";
$on_switch = "";
}
$is_checked = ($value == 'true') ? ' checked="checked"' : '';
printf('<div class="essb-switch">
<label class="cb-enable%6$s"><span>%4$s</span></label>
<label class="cb-disable%7$s"><span>%5$s</span></label>
<input id="essb_options_%1$s" type="checkbox" name="%2$s[%1$s]" value="true" class="input-element checkbox" %3$s />
</div>', $field, $settings_group, $is_checked, $on_text, $off_text, $on_switch, $off_switch);
}
public static function draw_input_field($field_id, $fullwidth = false, $settings_group = 'essb_options', $value = '', $icon = '', $class = '', $icon_position = '') {
if ($icon != '' && $icon_position != 'right') {
printf('<span class="essb-input-prefix-icon"><i class="fa %1$s"></i></span>', $icon);
}
echo '<input id="essb_options_' . $field_id . '" type="text" name="' . $settings_group . '[' . $field_id . ']" value="' . $value . '" class="input-element' . ($fullwidth ? ' stretched' : '') . ' '.$class.'" />';
if ($icon != '' && $icon_position == 'right') {
printf('<span class="essb-input-suffix-icon"><i class="fa %1$s"></i></span>', $icon);
}
}
public static function draw_fileselect_field($field_id, $settings_group = 'essb_options', $value = '', $icon = '', $class = '') {
if ($icon != '') {
printf('<span class="essb-input-prefix-icon"><i class="fa %1$s"></i></span>', $icon);
}
if (function_exists ( 'wp_enqueue_media' )) {
wp_enqueue_media ();
} else {
wp_enqueue_style ( 'thickbox' );
wp_enqueue_script ( 'media-upload' );
wp_enqueue_script ( 'thickbox' );
}
echo '<input id="essb_options_' . $field_id . '" type="text" name="' . $settings_group . '[' . $field_id . ']" value="' . $value . '" class="input-element small-stretched '.$class.'" />';
echo '<a href="#" class="button" id="essb_fileselect_' . $field_id . '">'.__('Select File', ESSB3_TEXT_DOMAIN).'</a>';
?>
<script type="text/javascript">
jQuery(document).ready(function($){
var custom_uploader;
$('#essb_fileselect_<?php echo $field_id; ?>').click(function(e) {
e.preventDefault();
//If the uploader object has already been created, reopen the dialog
if (custom_uploader) {
custom_uploader.open();
return;
}
//Extend the wp.media object
custom_uploader = wp.media.frames.file_frame = wp.media({
title: 'Select File',
button: {
text: 'Select File'
},
multiple: false
});
//When a file is selected, grab the URL and set it as the text field's value
custom_uploader.on('select', function() {
attachment = custom_uploader.state().get('selection').first().toJSON();
$('#essb_options_<?php echo $field_id; ?>').val(attachment.url);
});
//Open the uploader dialog
custom_uploader.open();
});
});
</script>
<?php
}
public static function draw_select_field($field, $listOfValues, $simpleList = false, $group = 'essb_options', $value = '') {
echo '<select name="' . $group . '[' . $field . ']" class="input-element" id="essb_options_' . $field . '">';
if ($simpleList) {
foreach ( $listOfValues as $singleValue ) {
printf ( '<option value="%1$s" %2$s>%1$s</option>', $singleValue, ($singleValue == $value ? 'selected' : '') );
}
} else {
foreach ( $listOfValues as $singleValueCode => $singleValue ) {
printf ( '<option value="%s" %s>%s</option>', $singleValueCode, ($singleValueCode == $value ? 'selected' : ''), $singleValue );
}
}
echo '</select>';
}
public static function draw_select2_field($field, $listOfValues, $simpleList = false, $group = 'essb_options', $value = '', $select2_options = array()) {
$allow_clear = isset($select2_options['allow_clear']) ? $select2_options['allow_clear'] : false;
$multiple = isset($select2_options['multiple']) ? $select2_options['multiple'] : false;
$placeholder = isset($select2_options['placeholder']) ? $select2_options['placeholder'] : false;
$allow_clear_state = ($allow_clear) ? "true" : "false";
echo '<select name="' . $group . '[' . $field . ']" class="input-element '.($multiple ? 'stretched' : "").'" id="essb_options_' . $field . '" '.($multiple ? 'multiple="multiple"' : "").'>';
if ($simpleList) {
foreach ( $listOfValues as $singleValue ) {
printf ( '<option value="%1$s" %2$s>%1$s</option>', $singleValue, ($singleValue == $value ? 'selected' : '') );
}
} else {
foreach ( $listOfValues as $singleValueCode => $singleValue ) {
printf ( '<option value="%s" %s>%s</option>', $singleValueCode, ($singleValueCode == $value ? 'selected' : ''), $singleValue );
}
}
echo '</select>';
echo '<script type="text/javascript">jQuery(document).ready(function($){
jQuery("#essb_options_' . $field . '").select2({
placeholder: "'.$placeholder.'",
allowClear: '.$allow_clear_state.'
});});</script>';
}
public static function draw_checkbox_field($field, $group = 'essb_options', $value = '') {
$is_checked = ($value == 'true') ? ' checked="checked"' : '';
echo '<input id="essb_options_' . $field . '" type="checkbox" name="' . $group . '[' . $field . ']" value="true" ' . $is_checked . ' />';
}
public static function draw_checkbox_list_field($field, $listOfValues, $group = 'essb_options', $value = '') {
if (!is_array($value)) { $value = array(); }
foreach ($listOfValues as $key => $text) {
$is_checked = in_array($key, $value) ? ' checked="checked"' : '';
echo '<span class="essb_checkbox_list_item"><input id="essb_options_' . $field . '" type="checkbox" name="' . $group . '[' . $field . '][]" value="'.$key.'" ' . $is_checked . ' />'.$text.'</span>';
}
}
public static function draw_checkbox_list_sortable_field($field, $listOfValues, $group = 'essb_options', $value = '') {
if (!is_array($value)) {
$value = array();
}
/*
* printf('<ul class="essb_sortable" id="essb-sortable-%1$s">', $field);
foreach ($value as $single) {
printf('<li>%1$s<input type="hidden" name="%2$s[%3$s][]" value="%1$s"/></li>', $single, $settings_group, $field);
}
echo '</ul>';
*/
printf('<ul class="essb_sortable" id="essb-sortable-%1$s">', $field);
foreach ($listOfValues as $key => $text) {
$is_checked = in_array($key, $value) ? ' checked="checked"' : '';
echo '<li><span class="essb_checkbox_list_item"><input id="essb_options_' . $field . '" type="checkbox" name="' . $group . '[' . $field . '][]" value="'.$key.'" ' . $is_checked . ' />'.$text.'<input type="hidden" name="' . $group . '[' . $field . '_order][]" value="'.$key.'|'.$text.'"/></span></li>';
}
echo '</ul>';
}
public static function draw_color_field($field, $group = 'essb_options', $value = '') {
$value = stripslashes ( $value );
echo '<input id="essb_options_' . $field . '" type="text" name="' . $group . '[' . $field . ']" value="' . $value . '" class="input-element stretched" data-default-color="' . $value . '" />';
array_push ( self::$color_fields, 'essb_options_' . $field );
}
public static function reset_color_selector() {
self::$color_fields = array();
}
public static function register_color_selector() {
?>
<div id="colorpicker"></div>
<script type="text/javascript">
jQuery(document).ready(function($){
<?php
foreach ( self::$color_fields as $single ) {
print "$('#" . $single . "').wpColorPicker();";
}
?>
});
</script>
<?php
}
public static function translate_key_array($array) {
if (!is_array($array)) { return array(); }
$key_array = array();
foreach ($array as $text_value) {
$keys = explode('|', $text_value);
$key = $keys[0];
$text = $keys[1];
$key_array[$key] = $text;
}
return $key_array;
}
}
?>
|
AntojandoAndo/AntojandoAndo
|
wp-content/plugins/easy-social-share-buttons3/lib/core/options/essb-matebox-options-framework.php
|
PHP
|
gpl-2.0
| 22,647 |
namespace GW2NET.Worlds
{
public enum Population
{
Unknown,
Low,
Medium,
High,
VeryHigh,
Full
}
}
|
StevenLiekens/GW2.NET
|
src/GW2NET.Core/Worlds/Population.cs
|
C#
|
gpl-2.0
| 165 |
var gmap_attrs = ['title', 'type', 'lat', 'long', 'zoom', 'viewtype', 'pin', 'map_height', 'map_color', 'animation', 'extra_class', 'visibility'];
function get_blox_element_googlemaps($content, $attrs){
return '<div class="blox_item blox_gmap" '+($attrs!=undefined ? $attrs : '')+'> \
<div class="blox_item_title"> \
<i class="fa-user"></i> \
<span class="blox_item_title">Google Maps</span> \
'+ get_blox_actions() +' \
</div> \
<div class="blox_item_content" style="display: none;">'+($content!=undefined ? $content : '')+'</div> \
</div>';
}
function parse_shortcode_googlemaps($content){
$content = wp.shortcode.replace( 'blox_gmap', $content, function(data){
var attrs = '';
jQuery.each(data.attrs.named, function(key, value){
if( value!=undefined && value!='undefined' && value!='' ){
attrs += key+'="'+ value +'" ';
}
});
return get_blox_element_googlemaps(data.content, attrs);
});
return $content;
}
function revert_shortcode_googlemaps($content){
$content.find('.blox_gmap').each(function(){
attr = '';
var temp_val = '';
for (var i = 0; i < gmap_attrs.length; i++) {
temp_val = jQuery(this).attr(gmap_attrs[i])+'';
if( temp_val!='undefined' && temp_val!='' ){
attr += ' '+ gmap_attrs[i] +'="'+ temp_val +'"';
}
}
jQuery(this).replaceWith('[blox_gmap'+attr+']'+jQuery(this).find('> .blox_item_content').html()+'[/blox_gmap]');
});
return $content;
}
function add_event_blox_element_googlemaps(){
jQuery('.blox_gmap').each(function(){
var $this = jQuery(this);
$this.find('.blox_item_actions .action_edit').unbind('click')
.click(function(){
var form_element = [
{
type: 'input',
id: 'blox_element_option_title',
label: 'Title',
value: $this.attr('title')
},
{
type: 'select',
id: 'blox_element_option_select',
label: 'Map Source Type',
value: $this.attr('type'),
options: [
{value: 'embed',label: 'Embed code'},
{value: 'custom',label: 'Custom map settings'}
]
},
{
type: 'textarea',
id: 'blox_element_option_embed',
label: 'Map Embed',
value: $this.find('.blox_item_content').html()
},
{
type: 'input',
id: 'blox_element_option_lat',
label: 'Latitude',
value: $this.attr('lat'),
std: '48.856614',
description: 'Latitude: 48.856614'
},
{
type: 'input',
id: 'blox_element_option_long',
label: 'Longitute',
value: $this.attr('long'),
std: '2.352222',
description: 'Longitute: 2.352222'
},
{
type: 'select',
id: 'blox_element_option_type',
label: 'View Type',
value: $this.attr('viewtype'),
options: [
{value: 'ROADMAP',label: 'Map'},
{value: 'SATELLITE',label: 'Satellite'},
{value: 'TERRAIN',label: 'Terrain'}
]
},
{
type: 'input',
id: 'blox_element_option_mapcolor',
label: 'Map Color',
value: $this.attr('map_color'),
std: '',
description: 'Default value is blank, You can select map hue color.'
},
{
type: 'image',
id: 'blox_element_option_pin',
label: 'Image',
value: $this.attr('pin')
},
{
type: 'number',
id: 'blox_element_option_zoom',
label: 'Zoom',
std: 14,
value: $this.attr('zoom'),
description: 'Zoom value have to 1 to 20. Default: 14.'
},
{
type: 'number',
id: 'blox_element_option_height',
label: 'Map Height',
std: 400,
value: $this.attr('map_height')
}
];
show_blox_form('Edit Google Map', form_element, function($form){
$this.attr('title', jQuery('#blox_element_option_title').val() );
$this.attr('type', jQuery('#blox_element_option_select').val() );
$this.attr('lat', jQuery('#blox_element_option_lat').val() );
$this.attr('long', jQuery('#blox_element_option_long').val() );
$this.attr('zoom', jQuery('#blox_element_option_zoom').val() );
$this.attr('viewtype', jQuery('#blox_element_option_type').val() );
$this.attr('pin', jQuery('#blox_element_option_pin').val() );
$this.attr('map_color', jQuery('#blox_element_option_mapcolor').val() );
$this.attr('map_height', jQuery('#blox_element_option_height').val() );
$this.find('.blox_item_content').html( jQuery('#blox_element_option_embed').val() );
},{
target: $this,
extra_field: true,
visibility: true
});
jQuery('#blox_element_option_select').change(function(){
if( this.value=='embed' ){
jQuery('#blox_element_option_embed').parent().show();
jQuery('#blox_element_option_lat,#blox_element_option_long,#blox_element_option_type, #blox_element_option_zoom,#blox_element_option_height,#blox_element_option_pin,#blox_element_option_mapcolor').parent().hide();
}
else{
jQuery('#blox_element_option_embed').parent().hide();
jQuery('#blox_element_option_lat,#blox_element_option_long,#blox_element_option_type, #blox_element_option_zoom,#blox_element_option_height,#blox_element_option_pin,#blox_element_option_mapcolor').parent().show();
}
});
jQuery('#blox_element_option_select').change();
});
$this.find('.blox_item_actions .action_clone').unbind('click')
.click(function(){
$this.after($this.clone());
add_event_blox_element_googlemaps();
});
$this.find('.blox_item_actions .action_remove').unbind('click')
.click(function(){
$this.remove();
});
});
}
|
JenilynnB/carnaby
|
wp-content/themes/ammo/framework/Pagebuilder/items/googlemaps/googlemaps.js
|
JavaScript
|
gpl-2.0
| 6,892 |
/* IO Code translation/library interface
Copyright (C) 2002-2013 Free Software Foundation, Inc.
Contributed by Paul Brook
This file is part of GCC.
GCC 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, or (at your option) any later
version.
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tree.h"
#include "ggc.h"
#include "diagnostic-core.h" /* For internal_error. */
#include "gfortran.h"
#include "trans.h"
#include "trans-stmt.h"
#include "trans-array.h"
#include "trans-types.h"
#include "trans-const.h"
/* Members of the ioparm structure. */
enum ioparam_type
{
IOPARM_ptype_common,
IOPARM_ptype_open,
IOPARM_ptype_close,
IOPARM_ptype_filepos,
IOPARM_ptype_inquire,
IOPARM_ptype_dt,
IOPARM_ptype_wait,
IOPARM_ptype_num
};
enum iofield_type
{
IOPARM_type_int4,
IOPARM_type_intio,
IOPARM_type_pint4,
IOPARM_type_pintio,
IOPARM_type_pchar,
IOPARM_type_parray,
IOPARM_type_pad,
IOPARM_type_char1,
IOPARM_type_char2,
IOPARM_type_common,
IOPARM_type_num
};
typedef struct GTY(()) gfc_st_parameter_field {
const char *name;
unsigned int mask;
enum ioparam_type param_type;
enum iofield_type type;
tree field;
tree field_len;
}
gfc_st_parameter_field;
typedef struct GTY(()) gfc_st_parameter {
const char *name;
tree type;
}
gfc_st_parameter;
enum iofield
{
#define IOPARM(param_type, name, mask, type) IOPARM_##param_type##_##name,
#include "ioparm.def"
#undef IOPARM
IOPARM_field_num
};
static GTY(()) gfc_st_parameter st_parameter[] =
{
{ "common", NULL },
{ "open", NULL },
{ "close", NULL },
{ "filepos", NULL },
{ "inquire", NULL },
{ "dt", NULL },
{ "wait", NULL }
};
static GTY(()) gfc_st_parameter_field st_parameter_field[] =
{
#define IOPARM(param_type, name, mask, type) \
{ #name, mask, IOPARM_ptype_##param_type, IOPARM_type_##type, NULL, NULL },
#include "ioparm.def"
#undef IOPARM
{ NULL, 0, (enum ioparam_type) 0, (enum iofield_type) 0, NULL, NULL }
};
/* Library I/O subroutines */
enum iocall
{
IOCALL_READ,
IOCALL_READ_DONE,
IOCALL_WRITE,
IOCALL_WRITE_DONE,
IOCALL_X_INTEGER,
IOCALL_X_INTEGER_WRITE,
IOCALL_X_LOGICAL,
IOCALL_X_LOGICAL_WRITE,
IOCALL_X_CHARACTER,
IOCALL_X_CHARACTER_WRITE,
IOCALL_X_CHARACTER_WIDE,
IOCALL_X_CHARACTER_WIDE_WRITE,
IOCALL_X_REAL,
IOCALL_X_REAL_WRITE,
IOCALL_X_COMPLEX,
IOCALL_X_COMPLEX_WRITE,
IOCALL_X_REAL128,
IOCALL_X_REAL128_WRITE,
IOCALL_X_COMPLEX128,
IOCALL_X_COMPLEX128_WRITE,
IOCALL_X_ARRAY,
IOCALL_X_ARRAY_WRITE,
IOCALL_OPEN,
IOCALL_CLOSE,
IOCALL_INQUIRE,
IOCALL_IOLENGTH,
IOCALL_IOLENGTH_DONE,
IOCALL_REWIND,
IOCALL_BACKSPACE,
IOCALL_ENDFILE,
IOCALL_FLUSH,
IOCALL_SET_NML_VAL,
IOCALL_SET_NML_VAL_DIM,
IOCALL_WAIT,
IOCALL_NUM
};
static GTY(()) tree iocall[IOCALL_NUM];
/* Variable for keeping track of what the last data transfer statement
was. Used for deciding which subroutine to call when the data
transfer is complete. */
static enum { READ, WRITE, IOLENGTH } last_dt;
/* The data transfer parameter block that should be shared by all
data transfer calls belonging to the same read/write/iolength. */
static GTY(()) tree dt_parm;
static stmtblock_t *dt_post_end_block;
static void
gfc_build_st_parameter (enum ioparam_type ptype, tree *types)
{
unsigned int type;
gfc_st_parameter_field *p;
char name[64];
size_t len;
tree t = make_node (RECORD_TYPE);
tree *chain = NULL;
len = strlen (st_parameter[ptype].name);
gcc_assert (len <= sizeof (name) - sizeof ("__st_parameter_"));
memcpy (name, "__st_parameter_", sizeof ("__st_parameter_"));
memcpy (name + sizeof ("__st_parameter_") - 1, st_parameter[ptype].name,
len + 1);
TYPE_NAME (t) = get_identifier (name);
for (type = 0, p = st_parameter_field; type < IOPARM_field_num; type++, p++)
if (p->param_type == ptype)
switch (p->type)
{
case IOPARM_type_int4:
case IOPARM_type_intio:
case IOPARM_type_pint4:
case IOPARM_type_pintio:
case IOPARM_type_parray:
case IOPARM_type_pchar:
case IOPARM_type_pad:
p->field = gfc_add_field_to_struct (t, get_identifier (p->name),
types[p->type], &chain);
break;
case IOPARM_type_char1:
p->field = gfc_add_field_to_struct (t, get_identifier (p->name),
pchar_type_node, &chain);
/* FALLTHROUGH */
case IOPARM_type_char2:
len = strlen (p->name);
gcc_assert (len <= sizeof (name) - sizeof ("_len"));
memcpy (name, p->name, len);
memcpy (name + len, "_len", sizeof ("_len"));
p->field_len = gfc_add_field_to_struct (t, get_identifier (name),
gfc_charlen_type_node,
&chain);
if (p->type == IOPARM_type_char2)
p->field = gfc_add_field_to_struct (t, get_identifier (p->name),
pchar_type_node, &chain);
break;
case IOPARM_type_common:
p->field
= gfc_add_field_to_struct (t,
get_identifier (p->name),
st_parameter[IOPARM_ptype_common].type,
&chain);
break;
case IOPARM_type_num:
gcc_unreachable ();
}
gfc_finish_type (t);
st_parameter[ptype].type = t;
}
/* Build code to test an error condition and call generate_error if needed.
Note: This builds calls to generate_error in the runtime library function.
The function generate_error is dependent on certain parameters in the
st_parameter_common flags to be set. (See libgfortran/runtime/error.c)
Therefore, the code to set these flags must be generated before
this function is used. */
void
gfc_trans_io_runtime_check (tree cond, tree var, int error_code,
const char * msgid, stmtblock_t * pblock)
{
stmtblock_t block;
tree body;
tree tmp;
tree arg1, arg2, arg3;
char *message;
if (integer_zerop (cond))
return;
/* The code to generate the error. */
gfc_start_block (&block);
arg1 = gfc_build_addr_expr (NULL_TREE, var);
arg2 = build_int_cst (integer_type_node, error_code),
asprintf (&message, "%s", _(msgid));
arg3 = gfc_build_addr_expr (pchar_type_node,
gfc_build_localized_cstring_const (message));
free (message);
tmp = build_call_expr_loc (input_location,
gfor_fndecl_generate_error, 3, arg1, arg2, arg3);
gfc_add_expr_to_block (&block, tmp);
body = gfc_finish_block (&block);
if (integer_onep (cond))
{
gfc_add_expr_to_block (pblock, body);
}
else
{
cond = gfc_unlikely (cond);
tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt (input_location));
gfc_add_expr_to_block (pblock, tmp);
}
}
/* Create function decls for IO library functions. */
void
gfc_build_io_library_fndecls (void)
{
tree types[IOPARM_type_num], pad_idx, gfc_int4_type_node;
tree gfc_intio_type_node;
tree parm_type, dt_parm_type;
HOST_WIDE_INT pad_size;
unsigned int ptype;
types[IOPARM_type_int4] = gfc_int4_type_node = gfc_get_int_type (4);
types[IOPARM_type_intio] = gfc_intio_type_node
= gfc_get_int_type (gfc_intio_kind);
types[IOPARM_type_pint4] = build_pointer_type (gfc_int4_type_node);
types[IOPARM_type_pintio]
= build_pointer_type (gfc_intio_type_node);
types[IOPARM_type_parray] = pchar_type_node;
types[IOPARM_type_pchar] = pchar_type_node;
pad_size = 16 * TREE_INT_CST_LOW (TYPE_SIZE_UNIT (pchar_type_node));
pad_size += 32 * TREE_INT_CST_LOW (TYPE_SIZE_UNIT (integer_type_node));
pad_idx = build_index_type (size_int (pad_size - 1));
types[IOPARM_type_pad] = build_array_type (char_type_node, pad_idx);
/* pad actually contains pointers and integers so it needs to have an
alignment that is at least as large as the needed alignment for those
types. See the st_parameter_dt structure in libgfortran/io/io.h for
what really goes into this space. */
TYPE_ALIGN (types[IOPARM_type_pad]) = MAX (TYPE_ALIGN (pchar_type_node),
TYPE_ALIGN (gfc_get_int_type (gfc_intio_kind)));
for (ptype = IOPARM_ptype_common; ptype < IOPARM_ptype_num; ptype++)
gfc_build_st_parameter ((enum ioparam_type) ptype, types);
/* Define the transfer functions. */
dt_parm_type = build_pointer_type (st_parameter[IOPARM_ptype_dt].type);
iocall[IOCALL_X_INTEGER] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_integer")), ".wW",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_INTEGER_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_integer_write")), ".wR",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_LOGICAL] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_logical")), ".wW",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_LOGICAL_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_logical_write")), ".wR",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_CHARACTER] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_character")), ".wW",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_CHARACTER_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_character_write")), ".wR",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_CHARACTER_WIDE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_character_wide")), ".wW",
void_type_node, 4, dt_parm_type, pvoid_type_node,
gfc_charlen_type_node, gfc_int4_type_node);
iocall[IOCALL_X_CHARACTER_WIDE_WRITE] =
gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_character_wide_write")), ".wR",
void_type_node, 4, dt_parm_type, pvoid_type_node,
gfc_charlen_type_node, gfc_int4_type_node);
iocall[IOCALL_X_REAL] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_real")), ".wW",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_REAL_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_real_write")), ".wR",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_COMPLEX] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_complex")), ".wW",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_COMPLEX_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_complex_write")), ".wR",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
/* Version for __float128. */
iocall[IOCALL_X_REAL128] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_real128")), ".wW",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_REAL128_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_real128_write")), ".wR",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_COMPLEX128] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_complex128")), ".wW",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_COMPLEX128_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_complex128_write")), ".wR",
void_type_node, 3, dt_parm_type, pvoid_type_node, gfc_int4_type_node);
iocall[IOCALL_X_ARRAY] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_array")), ".ww",
void_type_node, 4, dt_parm_type, pvoid_type_node,
integer_type_node, gfc_charlen_type_node);
iocall[IOCALL_X_ARRAY_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("transfer_array_write")), ".wr",
void_type_node, 4, dt_parm_type, pvoid_type_node,
integer_type_node, gfc_charlen_type_node);
/* Library entry points */
iocall[IOCALL_READ] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_read")), ".w",
void_type_node, 1, dt_parm_type);
iocall[IOCALL_WRITE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_write")), ".w",
void_type_node, 1, dt_parm_type);
parm_type = build_pointer_type (st_parameter[IOPARM_ptype_open].type);
iocall[IOCALL_OPEN] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_open")), ".w",
void_type_node, 1, parm_type);
parm_type = build_pointer_type (st_parameter[IOPARM_ptype_close].type);
iocall[IOCALL_CLOSE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_close")), ".w",
void_type_node, 1, parm_type);
parm_type = build_pointer_type (st_parameter[IOPARM_ptype_inquire].type);
iocall[IOCALL_INQUIRE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_inquire")), ".w",
void_type_node, 1, parm_type);
iocall[IOCALL_IOLENGTH] = gfc_build_library_function_decl_with_spec(
get_identifier (PREFIX("st_iolength")), ".w",
void_type_node, 1, dt_parm_type);
/* TODO: Change when asynchronous I/O is implemented. */
parm_type = build_pointer_type (st_parameter[IOPARM_ptype_wait].type);
iocall[IOCALL_WAIT] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_wait")), ".X",
void_type_node, 1, parm_type);
parm_type = build_pointer_type (st_parameter[IOPARM_ptype_filepos].type);
iocall[IOCALL_REWIND] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_rewind")), ".w",
void_type_node, 1, parm_type);
iocall[IOCALL_BACKSPACE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_backspace")), ".w",
void_type_node, 1, parm_type);
iocall[IOCALL_ENDFILE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_endfile")), ".w",
void_type_node, 1, parm_type);
iocall[IOCALL_FLUSH] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_flush")), ".w",
void_type_node, 1, parm_type);
/* Library helpers */
iocall[IOCALL_READ_DONE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_read_done")), ".w",
void_type_node, 1, dt_parm_type);
iocall[IOCALL_WRITE_DONE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_write_done")), ".w",
void_type_node, 1, dt_parm_type);
iocall[IOCALL_IOLENGTH_DONE] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_iolength_done")), ".w",
void_type_node, 1, dt_parm_type);
iocall[IOCALL_SET_NML_VAL] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_set_nml_var")), ".w.R",
void_type_node, 6, dt_parm_type, pvoid_type_node, pvoid_type_node,
void_type_node, gfc_charlen_type_node, gfc_int4_type_node);
iocall[IOCALL_SET_NML_VAL_DIM] = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("st_set_nml_var_dim")), ".w",
void_type_node, 5, dt_parm_type, gfc_int4_type_node,
gfc_array_index_type, gfc_array_index_type, gfc_array_index_type);
}
/* Generate code to store an integer constant into the
st_parameter_XXX structure. */
static unsigned int
set_parameter_const (stmtblock_t *block, tree var, enum iofield type,
unsigned int val)
{
tree tmp;
gfc_st_parameter_field *p = &st_parameter_field[type];
if (p->param_type == IOPARM_ptype_common)
var = fold_build3_loc (input_location, COMPONENT_REF,
st_parameter[IOPARM_ptype_common].type,
var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
var, p->field, NULL_TREE);
gfc_add_modify (block, tmp, build_int_cst (TREE_TYPE (p->field), val));
return p->mask;
}
/* Generate code to store a non-string I/O parameter into the
st_parameter_XXX structure. This is a pass by value. */
static unsigned int
set_parameter_value (stmtblock_t *block, tree var, enum iofield type,
gfc_expr *e)
{
gfc_se se;
tree tmp;
gfc_st_parameter_field *p = &st_parameter_field[type];
tree dest_type = TREE_TYPE (p->field);
gfc_init_se (&se, NULL);
gfc_conv_expr_val (&se, e);
/* If we're storing a UNIT number, we need to check it first. */
if (type == IOPARM_common_unit && e->ts.kind > 4)
{
tree cond, val;
int i;
/* Don't evaluate the UNIT number multiple times. */
se.expr = gfc_evaluate_now (se.expr, &se.pre);
/* UNIT numbers should be greater than the min. */
i = gfc_validate_kind (BT_INTEGER, 4, false);
val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].pedantic_min_int, 4);
cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
se.expr,
fold_convert (TREE_TYPE (se.expr), val));
gfc_trans_io_runtime_check (cond, var, LIBERROR_BAD_UNIT,
"Unit number in I/O statement too small",
&se.pre);
/* UNIT numbers should be less than the max. */
val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4);
cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
se.expr,
fold_convert (TREE_TYPE (se.expr), val));
gfc_trans_io_runtime_check (cond, var, LIBERROR_BAD_UNIT,
"Unit number in I/O statement too large",
&se.pre);
}
se.expr = convert (dest_type, se.expr);
gfc_add_block_to_block (block, &se.pre);
if (p->param_type == IOPARM_ptype_common)
var = fold_build3_loc (input_location, COMPONENT_REF,
st_parameter[IOPARM_ptype_common].type,
var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
tmp = fold_build3_loc (input_location, COMPONENT_REF, dest_type, var,
p->field, NULL_TREE);
gfc_add_modify (block, tmp, se.expr);
return p->mask;
}
/* Generate code to store a non-string I/O parameter into the
st_parameter_XXX structure. This is pass by reference. */
static unsigned int
set_parameter_ref (stmtblock_t *block, stmtblock_t *postblock,
tree var, enum iofield type, gfc_expr *e)
{
gfc_se se;
tree tmp, addr;
gfc_st_parameter_field *p = &st_parameter_field[type];
gcc_assert (e->ts.type == BT_INTEGER || e->ts.type == BT_LOGICAL);
gfc_init_se (&se, NULL);
gfc_conv_expr_lhs (&se, e);
gfc_add_block_to_block (block, &se.pre);
if (TYPE_MODE (TREE_TYPE (se.expr))
== TYPE_MODE (TREE_TYPE (TREE_TYPE (p->field))))
{
addr = convert (TREE_TYPE (p->field), gfc_build_addr_expr (NULL_TREE, se.expr));
/* If this is for the iostat variable initialize the
user variable to LIBERROR_OK which is zero. */
if (type == IOPARM_common_iostat)
gfc_add_modify (block, se.expr,
build_int_cst (TREE_TYPE (se.expr), LIBERROR_OK));
}
else
{
/* The type used by the library has different size
from the type of the variable supplied by the user.
Need to use a temporary. */
tree tmpvar = gfc_create_var (TREE_TYPE (TREE_TYPE (p->field)),
st_parameter_field[type].name);
/* If this is for the iostat variable, initialize the
user variable to LIBERROR_OK which is zero. */
if (type == IOPARM_common_iostat)
gfc_add_modify (block, tmpvar,
build_int_cst (TREE_TYPE (tmpvar), LIBERROR_OK));
addr = gfc_build_addr_expr (NULL_TREE, tmpvar);
/* After the I/O operation, we set the variable from the temporary. */
tmp = convert (TREE_TYPE (se.expr), tmpvar);
gfc_add_modify (postblock, se.expr, tmp);
}
if (p->param_type == IOPARM_ptype_common)
var = fold_build3_loc (input_location, COMPONENT_REF,
st_parameter[IOPARM_ptype_common].type,
var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
var, p->field, NULL_TREE);
gfc_add_modify (block, tmp, addr);
return p->mask;
}
/* Given an array expr, find its address and length to get a string. If the
array is full, the string's address is the address of array's first element
and the length is the size of the whole array. If it is an element, the
string's address is the element's address and the length is the rest size of
the array. */
static void
gfc_convert_array_to_string (gfc_se * se, gfc_expr * e)
{
tree size;
if (e->rank == 0)
{
tree type, array, tmp;
gfc_symbol *sym;
int rank;
/* If it is an element, we need its address and size of the rest. */
gcc_assert (e->expr_type == EXPR_VARIABLE);
gcc_assert (e->ref->u.ar.type == AR_ELEMENT);
sym = e->symtree->n.sym;
rank = sym->as->rank - 1;
gfc_conv_expr (se, e);
array = sym->backend_decl;
type = TREE_TYPE (array);
if (GFC_ARRAY_TYPE_P (type))
size = GFC_TYPE_ARRAY_SIZE (type);
else
{
gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
size = gfc_conv_array_stride (array, rank);
tmp = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type,
gfc_conv_array_ubound (array, rank),
gfc_conv_array_lbound (array, rank));
tmp = fold_build2_loc (input_location, PLUS_EXPR,
gfc_array_index_type, tmp,
gfc_index_one_node);
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, tmp, size);
}
gcc_assert (size);
size = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type, size,
TREE_OPERAND (se->expr, 1));
se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size,
fold_convert (gfc_array_index_type, tmp));
se->string_length = fold_convert (gfc_charlen_type_node, size);
return;
}
gfc_conv_array_parameter (se, e, true, NULL, NULL, &size);
se->string_length = fold_convert (gfc_charlen_type_node, size);
}
/* Generate code to store a string and its length into the
st_parameter_XXX structure. */
static unsigned int
set_string (stmtblock_t * block, stmtblock_t * postblock, tree var,
enum iofield type, gfc_expr * e)
{
gfc_se se;
tree tmp;
tree io;
tree len;
gfc_st_parameter_field *p = &st_parameter_field[type];
gfc_init_se (&se, NULL);
if (p->param_type == IOPARM_ptype_common)
var = fold_build3_loc (input_location, COMPONENT_REF,
st_parameter[IOPARM_ptype_common].type,
var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
io = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
var, p->field, NULL_TREE);
len = fold_build3_loc (input_location, COMPONENT_REF,
TREE_TYPE (p->field_len),
var, p->field_len, NULL_TREE);
/* Integer variable assigned a format label. */
if (e->ts.type == BT_INTEGER
&& e->rank == 0
&& e->symtree->n.sym->attr.assign == 1)
{
char * msg;
tree cond;
gfc_conv_label_variable (&se, e);
tmp = GFC_DECL_STRING_LEN (se.expr);
cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
tmp, build_int_cst (TREE_TYPE (tmp), 0));
asprintf(&msg, "Label assigned to variable '%s' (%%ld) is not a format "
"label", e->symtree->name);
gfc_trans_runtime_check (true, false, cond, &se.pre, &e->where, msg,
fold_convert (long_integer_type_node, tmp));
free (msg);
gfc_add_modify (&se.pre, io,
fold_convert (TREE_TYPE (io), GFC_DECL_ASSIGN_ADDR (se.expr)));
gfc_add_modify (&se.pre, len, GFC_DECL_STRING_LEN (se.expr));
}
else
{
/* General character. */
if (e->ts.type == BT_CHARACTER && e->rank == 0)
gfc_conv_expr (&se, e);
/* Array assigned Hollerith constant or character array. */
else if (e->rank > 0 || (e->symtree && e->symtree->n.sym->as->rank > 0))
gfc_convert_array_to_string (&se, e);
else
gcc_unreachable ();
gfc_conv_string_parameter (&se);
gfc_add_modify (&se.pre, io, fold_convert (TREE_TYPE (io), se.expr));
gfc_add_modify (&se.pre, len, se.string_length);
}
gfc_add_block_to_block (block, &se.pre);
gfc_add_block_to_block (postblock, &se.post);
return p->mask;
}
/* Generate code to store the character (array) and the character length
for an internal unit. */
static unsigned int
set_internal_unit (stmtblock_t * block, stmtblock_t * post_block,
tree var, gfc_expr * e)
{
gfc_se se;
tree io;
tree len;
tree desc;
tree tmp;
gfc_st_parameter_field *p;
unsigned int mask;
gfc_init_se (&se, NULL);
p = &st_parameter_field[IOPARM_dt_internal_unit];
mask = p->mask;
io = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
var, p->field, NULL_TREE);
len = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field_len),
var, p->field_len, NULL_TREE);
p = &st_parameter_field[IOPARM_dt_internal_unit_desc];
desc = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
var, p->field, NULL_TREE);
gcc_assert (e->ts.type == BT_CHARACTER);
/* Character scalars. */
if (e->rank == 0)
{
gfc_conv_expr (&se, e);
gfc_conv_string_parameter (&se);
tmp = se.expr;
se.expr = build_int_cst (pchar_type_node, 0);
}
/* Character array. */
else if (e->rank > 0)
{
if (is_subref_array (e))
{
/* Use a temporary for components of arrays of derived types
or substring array references. */
gfc_conv_subref_array_arg (&se, e, 0,
last_dt == READ ? INTENT_IN : INTENT_OUT, false);
tmp = build_fold_indirect_ref_loc (input_location,
se.expr);
se.expr = gfc_build_addr_expr (pchar_type_node, tmp);
tmp = gfc_conv_descriptor_data_get (tmp);
}
else
{
/* Return the data pointer and rank from the descriptor. */
gfc_conv_expr_descriptor (&se, e);
tmp = gfc_conv_descriptor_data_get (se.expr);
se.expr = gfc_build_addr_expr (pchar_type_node, se.expr);
}
}
else
gcc_unreachable ();
/* The cast is needed for character substrings and the descriptor
data. */
gfc_add_modify (&se.pre, io, fold_convert (TREE_TYPE (io), tmp));
gfc_add_modify (&se.pre, len,
fold_convert (TREE_TYPE (len), se.string_length));
gfc_add_modify (&se.pre, desc, se.expr);
gfc_add_block_to_block (block, &se.pre);
gfc_add_block_to_block (post_block, &se.post);
return mask;
}
/* Add a case to a IO-result switch. */
static void
add_case (int label_value, gfc_st_label * label, stmtblock_t * body)
{
tree tmp, value;
if (label == NULL)
return; /* No label, no case */
value = build_int_cst (integer_type_node, label_value);
/* Make a backend label for this case. */
tmp = gfc_build_label_decl (NULL_TREE);
/* And the case itself. */
tmp = build_case_label (value, NULL_TREE, tmp);
gfc_add_expr_to_block (body, tmp);
/* Jump to the label. */
tmp = build1_v (GOTO_EXPR, gfc_get_label_decl (label));
gfc_add_expr_to_block (body, tmp);
}
/* Generate a switch statement that branches to the correct I/O
result label. The last statement of an I/O call stores the
result into a variable because there is often cleanup that
must be done before the switch, so a temporary would have to
be created anyway. */
static void
io_result (stmtblock_t * block, tree var, gfc_st_label * err_label,
gfc_st_label * end_label, gfc_st_label * eor_label)
{
stmtblock_t body;
tree tmp, rc;
gfc_st_parameter_field *p = &st_parameter_field[IOPARM_common_flags];
/* If no labels are specified, ignore the result instead
of building an empty switch. */
if (err_label == NULL
&& end_label == NULL
&& eor_label == NULL)
return;
/* Build a switch statement. */
gfc_start_block (&body);
/* The label values here must be the same as the values
in the library_return enum in the runtime library */
add_case (1, err_label, &body);
add_case (2, end_label, &body);
add_case (3, eor_label, &body);
tmp = gfc_finish_block (&body);
var = fold_build3_loc (input_location, COMPONENT_REF,
st_parameter[IOPARM_ptype_common].type,
var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
rc = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
var, p->field, NULL_TREE);
rc = fold_build2_loc (input_location, BIT_AND_EXPR, TREE_TYPE (rc),
rc, build_int_cst (TREE_TYPE (rc),
IOPARM_common_libreturn_mask));
tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
rc, tmp, NULL_TREE);
gfc_add_expr_to_block (block, tmp);
}
/* Store the current file and line number to variables so that if a
library call goes awry, we can tell the user where the problem is. */
static void
set_error_locus (stmtblock_t * block, tree var, locus * where)
{
gfc_file *f;
tree str, locus_file;
int line;
gfc_st_parameter_field *p = &st_parameter_field[IOPARM_common_filename];
locus_file = fold_build3_loc (input_location, COMPONENT_REF,
st_parameter[IOPARM_ptype_common].type,
var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
locus_file = fold_build3_loc (input_location, COMPONENT_REF,
TREE_TYPE (p->field), locus_file,
p->field, NULL_TREE);
f = where->lb->file;
str = gfc_build_cstring_const (f->filename);
str = gfc_build_addr_expr (pchar_type_node, str);
gfc_add_modify (block, locus_file, str);
line = LOCATION_LINE (where->lb->location);
set_parameter_const (block, var, IOPARM_common_line, line);
}
/* Translate an OPEN statement. */
tree
gfc_trans_open (gfc_code * code)
{
stmtblock_t block, post_block;
gfc_open *p;
tree tmp, var;
unsigned int mask = 0;
gfc_start_block (&block);
gfc_init_block (&post_block);
var = gfc_create_var (st_parameter[IOPARM_ptype_open].type, "open_parm");
set_error_locus (&block, var, &code->loc);
p = code->ext.open;
if (p->iomsg)
mask |= set_string (&block, &post_block, var, IOPARM_common_iomsg,
p->iomsg);
if (p->iostat)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_common_iostat,
p->iostat);
if (p->err)
mask |= IOPARM_common_err;
if (p->file)
mask |= set_string (&block, &post_block, var, IOPARM_open_file, p->file);
if (p->status)
mask |= set_string (&block, &post_block, var, IOPARM_open_status,
p->status);
if (p->access)
mask |= set_string (&block, &post_block, var, IOPARM_open_access,
p->access);
if (p->form)
mask |= set_string (&block, &post_block, var, IOPARM_open_form, p->form);
if (p->recl)
mask |= set_parameter_value (&block, var, IOPARM_open_recl_in, p->recl);
if (p->blank)
mask |= set_string (&block, &post_block, var, IOPARM_open_blank,
p->blank);
if (p->position)
mask |= set_string (&block, &post_block, var, IOPARM_open_position,
p->position);
if (p->action)
mask |= set_string (&block, &post_block, var, IOPARM_open_action,
p->action);
if (p->delim)
mask |= set_string (&block, &post_block, var, IOPARM_open_delim,
p->delim);
if (p->pad)
mask |= set_string (&block, &post_block, var, IOPARM_open_pad, p->pad);
if (p->decimal)
mask |= set_string (&block, &post_block, var, IOPARM_open_decimal,
p->decimal);
if (p->encoding)
mask |= set_string (&block, &post_block, var, IOPARM_open_encoding,
p->encoding);
if (p->round)
mask |= set_string (&block, &post_block, var, IOPARM_open_round, p->round);
if (p->sign)
mask |= set_string (&block, &post_block, var, IOPARM_open_sign, p->sign);
if (p->asynchronous)
mask |= set_string (&block, &post_block, var, IOPARM_open_asynchronous,
p->asynchronous);
if (p->convert)
mask |= set_string (&block, &post_block, var, IOPARM_open_convert,
p->convert);
if (p->newunit)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_open_newunit,
p->newunit);
set_parameter_const (&block, var, IOPARM_common_flags, mask);
if (p->unit)
set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr_loc (input_location,
iocall[IOCALL_OPEN], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &post_block);
io_result (&block, var, p->err, NULL, NULL);
return gfc_finish_block (&block);
}
/* Translate a CLOSE statement. */
tree
gfc_trans_close (gfc_code * code)
{
stmtblock_t block, post_block;
gfc_close *p;
tree tmp, var;
unsigned int mask = 0;
gfc_start_block (&block);
gfc_init_block (&post_block);
var = gfc_create_var (st_parameter[IOPARM_ptype_close].type, "close_parm");
set_error_locus (&block, var, &code->loc);
p = code->ext.close;
if (p->iomsg)
mask |= set_string (&block, &post_block, var, IOPARM_common_iomsg,
p->iomsg);
if (p->iostat)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_common_iostat,
p->iostat);
if (p->err)
mask |= IOPARM_common_err;
if (p->status)
mask |= set_string (&block, &post_block, var, IOPARM_close_status,
p->status);
set_parameter_const (&block, var, IOPARM_common_flags, mask);
if (p->unit)
set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr_loc (input_location,
iocall[IOCALL_CLOSE], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &post_block);
io_result (&block, var, p->err, NULL, NULL);
return gfc_finish_block (&block);
}
/* Common subroutine for building a file positioning statement. */
static tree
build_filepos (tree function, gfc_code * code)
{
stmtblock_t block, post_block;
gfc_filepos *p;
tree tmp, var;
unsigned int mask = 0;
p = code->ext.filepos;
gfc_start_block (&block);
gfc_init_block (&post_block);
var = gfc_create_var (st_parameter[IOPARM_ptype_filepos].type,
"filepos_parm");
set_error_locus (&block, var, &code->loc);
if (p->iomsg)
mask |= set_string (&block, &post_block, var, IOPARM_common_iomsg,
p->iomsg);
if (p->iostat)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_common_iostat,
p->iostat);
if (p->err)
mask |= IOPARM_common_err;
set_parameter_const (&block, var, IOPARM_common_flags, mask);
if (p->unit)
set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr_loc (input_location,
function, 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &post_block);
io_result (&block, var, p->err, NULL, NULL);
return gfc_finish_block (&block);
}
/* Translate a BACKSPACE statement. */
tree
gfc_trans_backspace (gfc_code * code)
{
return build_filepos (iocall[IOCALL_BACKSPACE], code);
}
/* Translate an ENDFILE statement. */
tree
gfc_trans_endfile (gfc_code * code)
{
return build_filepos (iocall[IOCALL_ENDFILE], code);
}
/* Translate a REWIND statement. */
tree
gfc_trans_rewind (gfc_code * code)
{
return build_filepos (iocall[IOCALL_REWIND], code);
}
/* Translate a FLUSH statement. */
tree
gfc_trans_flush (gfc_code * code)
{
return build_filepos (iocall[IOCALL_FLUSH], code);
}
/* Create a dummy iostat variable to catch any error due to bad unit. */
static gfc_expr *
create_dummy_iostat (void)
{
gfc_symtree *st;
gfc_expr *e;
gfc_get_ha_sym_tree ("@iostat", &st);
st->n.sym->ts.type = BT_INTEGER;
st->n.sym->ts.kind = gfc_default_integer_kind;
gfc_set_sym_referenced (st->n.sym);
gfc_commit_symbol (st->n.sym);
st->n.sym->backend_decl
= gfc_create_var (gfc_get_int_type (st->n.sym->ts.kind),
st->n.sym->name);
e = gfc_get_expr ();
e->expr_type = EXPR_VARIABLE;
e->symtree = st;
e->ts.type = BT_INTEGER;
e->ts.kind = st->n.sym->ts.kind;
return e;
}
/* Translate the non-IOLENGTH form of an INQUIRE statement. */
tree
gfc_trans_inquire (gfc_code * code)
{
stmtblock_t block, post_block;
gfc_inquire *p;
tree tmp, var;
unsigned int mask = 0, mask2 = 0;
gfc_start_block (&block);
gfc_init_block (&post_block);
var = gfc_create_var (st_parameter[IOPARM_ptype_inquire].type,
"inquire_parm");
set_error_locus (&block, var, &code->loc);
p = code->ext.inquire;
if (p->iomsg)
mask |= set_string (&block, &post_block, var, IOPARM_common_iomsg,
p->iomsg);
if (p->iostat)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_common_iostat,
p->iostat);
if (p->err)
mask |= IOPARM_common_err;
/* Sanity check. */
if (p->unit && p->file)
gfc_error ("INQUIRE statement at %L cannot contain both FILE and UNIT specifiers", &code->loc);
if (p->file)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_file,
p->file);
if (p->exist)
{
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_exist,
p->exist);
if (p->unit && !p->iostat)
{
p->iostat = create_dummy_iostat ();
mask |= set_parameter_ref (&block, &post_block, var,
IOPARM_common_iostat, p->iostat);
}
}
if (p->opened)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_opened,
p->opened);
if (p->number)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_number,
p->number);
if (p->named)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_named,
p->named);
if (p->name)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_name,
p->name);
if (p->access)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_access,
p->access);
if (p->sequential)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_sequential,
p->sequential);
if (p->direct)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_direct,
p->direct);
if (p->form)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_form,
p->form);
if (p->formatted)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_formatted,
p->formatted);
if (p->unformatted)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_unformatted,
p->unformatted);
if (p->recl)
mask |= set_parameter_ref (&block, &post_block, var,
IOPARM_inquire_recl_out, p->recl);
if (p->nextrec)
mask |= set_parameter_ref (&block, &post_block, var,
IOPARM_inquire_nextrec, p->nextrec);
if (p->blank)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_blank,
p->blank);
if (p->delim)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_delim,
p->delim);
if (p->position)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_position,
p->position);
if (p->action)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_action,
p->action);
if (p->read)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_read,
p->read);
if (p->write)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_write,
p->write);
if (p->readwrite)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_readwrite,
p->readwrite);
if (p->pad)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_pad,
p->pad);
if (p->convert)
mask |= set_string (&block, &post_block, var, IOPARM_inquire_convert,
p->convert);
if (p->strm_pos)
mask |= set_parameter_ref (&block, &post_block, var,
IOPARM_inquire_strm_pos_out, p->strm_pos);
/* The second series of flags. */
if (p->asynchronous)
mask2 |= set_string (&block, &post_block, var, IOPARM_inquire_asynchronous,
p->asynchronous);
if (p->decimal)
mask2 |= set_string (&block, &post_block, var, IOPARM_inquire_decimal,
p->decimal);
if (p->encoding)
mask2 |= set_string (&block, &post_block, var, IOPARM_inquire_encoding,
p->encoding);
if (p->round)
mask2 |= set_string (&block, &post_block, var, IOPARM_inquire_round,
p->round);
if (p->sign)
mask2 |= set_string (&block, &post_block, var, IOPARM_inquire_sign,
p->sign);
if (p->pending)
mask2 |= set_parameter_ref (&block, &post_block, var,
IOPARM_inquire_pending, p->pending);
if (p->size)
mask2 |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_size,
p->size);
if (p->id)
mask2 |= set_parameter_ref (&block, &post_block,var, IOPARM_inquire_id,
p->id);
if (p->iqstream)
mask2 |= set_string (&block, &post_block, var, IOPARM_inquire_iqstream,
p->iqstream);
if (mask2)
mask |= set_parameter_const (&block, var, IOPARM_inquire_flags2, mask2);
set_parameter_const (&block, var, IOPARM_common_flags, mask);
if (p->unit)
set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr_loc (input_location,
iocall[IOCALL_INQUIRE], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &post_block);
io_result (&block, var, p->err, NULL, NULL);
return gfc_finish_block (&block);
}
tree
gfc_trans_wait (gfc_code * code)
{
stmtblock_t block, post_block;
gfc_wait *p;
tree tmp, var;
unsigned int mask = 0;
gfc_start_block (&block);
gfc_init_block (&post_block);
var = gfc_create_var (st_parameter[IOPARM_ptype_wait].type,
"wait_parm");
set_error_locus (&block, var, &code->loc);
p = code->ext.wait;
/* Set parameters here. */
if (p->iomsg)
mask |= set_string (&block, &post_block, var, IOPARM_common_iomsg,
p->iomsg);
if (p->iostat)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_common_iostat,
p->iostat);
if (p->err)
mask |= IOPARM_common_err;
if (p->id)
mask |= set_parameter_value (&block, var, IOPARM_wait_id, p->id);
set_parameter_const (&block, var, IOPARM_common_flags, mask);
if (p->unit)
set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr_loc (input_location,
iocall[IOCALL_WAIT], 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &post_block);
io_result (&block, var, p->err, NULL, NULL);
return gfc_finish_block (&block);
}
/* nml_full_name builds up the fully qualified name of a
derived type component. */
static char*
nml_full_name (const char* var_name, const char* cmp_name)
{
int full_name_length;
char * full_name;
full_name_length = strlen (var_name) + strlen (cmp_name) + 1;
full_name = XCNEWVEC (char, full_name_length + 1);
strcpy (full_name, var_name);
full_name = strcat (full_name, "%");
full_name = strcat (full_name, cmp_name);
return full_name;
}
/* nml_get_addr_expr builds an address expression from the
gfc_symbol or gfc_component backend_decl's. An offset is
provided so that the address of an element of an array of
derived types is returned. This is used in the runtime to
determine that span of the derived type. */
static tree
nml_get_addr_expr (gfc_symbol * sym, gfc_component * c,
tree base_addr)
{
tree decl = NULL_TREE;
tree tmp;
if (sym)
{
sym->attr.referenced = 1;
decl = gfc_get_symbol_decl (sym);
/* If this is the enclosing function declaration, use
the fake result instead. */
if (decl == current_function_decl)
decl = gfc_get_fake_result_decl (sym, 0);
else if (decl == DECL_CONTEXT (current_function_decl))
decl = gfc_get_fake_result_decl (sym, 1);
}
else
decl = c->backend_decl;
gcc_assert (decl && ((TREE_CODE (decl) == FIELD_DECL
|| TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL)
|| TREE_CODE (decl) == COMPONENT_REF));
tmp = decl;
/* Build indirect reference, if dummy argument. */
if (POINTER_TYPE_P (TREE_TYPE(tmp)))
tmp = build_fold_indirect_ref_loc (input_location, tmp);
/* Treat the component of a derived type, using base_addr for
the derived type. */
if (TREE_CODE (decl) == FIELD_DECL)
tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (tmp),
base_addr, tmp, NULL_TREE);
if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (tmp)))
tmp = gfc_conv_array_data (tmp);
else
{
if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
if (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
tmp = gfc_build_array_ref (tmp, gfc_index_zero_node, NULL);
if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
tmp = build_fold_indirect_ref_loc (input_location,
tmp);
}
gcc_assert (tmp && POINTER_TYPE_P (TREE_TYPE (tmp)));
return tmp;
}
/* For an object VAR_NAME whose base address is BASE_ADDR, generate a
call to iocall[IOCALL_SET_NML_VAL]. For derived type variable, recursively
generate calls to iocall[IOCALL_SET_NML_VAL] for each component. */
#define IARG(i) build_int_cst (gfc_array_index_type, i)
static void
transfer_namelist_element (stmtblock_t * block, const char * var_name,
gfc_symbol * sym, gfc_component * c,
tree base_addr)
{
gfc_typespec * ts = NULL;
gfc_array_spec * as = NULL;
tree addr_expr = NULL;
tree dt = NULL;
tree string;
tree tmp;
tree dtype;
tree dt_parm_addr;
tree decl = NULL_TREE;
int n_dim;
int itype;
int rank = 0;
gcc_assert (sym || c);
/* Build the namelist object name. */
string = gfc_build_cstring_const (var_name);
string = gfc_build_addr_expr (pchar_type_node, string);
/* Build ts, as and data address using symbol or component. */
ts = (sym) ? &sym->ts : &c->ts;
as = (sym) ? sym->as : c->as;
addr_expr = nml_get_addr_expr (sym, c, base_addr);
if (as)
rank = as->rank;
if (rank)
{
decl = (sym) ? sym->backend_decl : c->backend_decl;
if (sym && sym->attr.dummy)
decl = build_fold_indirect_ref_loc (input_location, decl);
dt = TREE_TYPE (decl);
dtype = gfc_get_dtype (dt);
}
else
{
itype = ts->type;
dtype = IARG (itype << GFC_DTYPE_TYPE_SHIFT);
}
/* Build up the arguments for the transfer call.
The call for the scalar part transfers:
(address, name, type, kind or string_length, dtype) */
dt_parm_addr = gfc_build_addr_expr (NULL_TREE, dt_parm);
if (ts->type == BT_CHARACTER)
tmp = ts->u.cl->backend_decl;
else
tmp = build_int_cst (gfc_charlen_type_node, 0);
tmp = build_call_expr_loc (input_location,
iocall[IOCALL_SET_NML_VAL], 6,
dt_parm_addr, addr_expr, string,
IARG (ts->kind), tmp, dtype);
gfc_add_expr_to_block (block, tmp);
/* If the object is an array, transfer rank times:
(null pointer, name, stride, lbound, ubound) */
for ( n_dim = 0 ; n_dim < rank ; n_dim++ )
{
tmp = build_call_expr_loc (input_location,
iocall[IOCALL_SET_NML_VAL_DIM], 5,
dt_parm_addr,
IARG (n_dim),
gfc_conv_array_stride (decl, n_dim),
gfc_conv_array_lbound (decl, n_dim),
gfc_conv_array_ubound (decl, n_dim));
gfc_add_expr_to_block (block, tmp);
}
if (ts->type == BT_DERIVED && ts->u.derived->components)
{
gfc_component *cmp;
/* Provide the RECORD_TYPE to build component references. */
tree expr = build_fold_indirect_ref_loc (input_location,
addr_expr);
for (cmp = ts->u.derived->components; cmp; cmp = cmp->next)
{
char *full_name = nml_full_name (var_name, cmp->name);
transfer_namelist_element (block,
full_name,
NULL, cmp, expr);
free (full_name);
}
}
}
#undef IARG
/* Create a data transfer statement. Not all of the fields are valid
for both reading and writing, but improper use has been filtered
out by now. */
static tree
build_dt (tree function, gfc_code * code)
{
stmtblock_t block, post_block, post_end_block, post_iu_block;
gfc_dt *dt;
tree tmp, var;
gfc_expr *nmlname;
gfc_namelist *nml;
unsigned int mask = 0;
gfc_start_block (&block);
gfc_init_block (&post_block);
gfc_init_block (&post_end_block);
gfc_init_block (&post_iu_block);
var = gfc_create_var (st_parameter[IOPARM_ptype_dt].type, "dt_parm");
set_error_locus (&block, var, &code->loc);
if (last_dt == IOLENGTH)
{
gfc_inquire *inq;
inq = code->ext.inquire;
/* First check that preconditions are met. */
gcc_assert (inq != NULL);
gcc_assert (inq->iolength != NULL);
/* Connect to the iolength variable. */
mask |= set_parameter_ref (&block, &post_end_block, var,
IOPARM_dt_iolength, inq->iolength);
dt = NULL;
}
else
{
dt = code->ext.dt;
gcc_assert (dt != NULL);
}
if (dt && dt->io_unit)
{
if (dt->io_unit->ts.type == BT_CHARACTER)
{
mask |= set_internal_unit (&block, &post_iu_block,
var, dt->io_unit);
set_parameter_const (&block, var, IOPARM_common_unit,
dt->io_unit->ts.kind == 1 ? 0 : -1);
}
}
else
set_parameter_const (&block, var, IOPARM_common_unit, 0);
if (dt)
{
if (dt->iomsg)
mask |= set_string (&block, &post_block, var, IOPARM_common_iomsg,
dt->iomsg);
if (dt->iostat)
mask |= set_parameter_ref (&block, &post_end_block, var,
IOPARM_common_iostat, dt->iostat);
if (dt->err)
mask |= IOPARM_common_err;
if (dt->eor)
mask |= IOPARM_common_eor;
if (dt->end)
mask |= IOPARM_common_end;
if (dt->id)
mask |= set_parameter_ref (&block, &post_end_block, var,
IOPARM_dt_id, dt->id);
if (dt->pos)
mask |= set_parameter_value (&block, var, IOPARM_dt_pos, dt->pos);
if (dt->asynchronous)
mask |= set_string (&block, &post_block, var, IOPARM_dt_asynchronous,
dt->asynchronous);
if (dt->blank)
mask |= set_string (&block, &post_block, var, IOPARM_dt_blank,
dt->blank);
if (dt->decimal)
mask |= set_string (&block, &post_block, var, IOPARM_dt_decimal,
dt->decimal);
if (dt->delim)
mask |= set_string (&block, &post_block, var, IOPARM_dt_delim,
dt->delim);
if (dt->pad)
mask |= set_string (&block, &post_block, var, IOPARM_dt_pad,
dt->pad);
if (dt->round)
mask |= set_string (&block, &post_block, var, IOPARM_dt_round,
dt->round);
if (dt->sign)
mask |= set_string (&block, &post_block, var, IOPARM_dt_sign,
dt->sign);
if (dt->rec)
mask |= set_parameter_value (&block, var, IOPARM_dt_rec, dt->rec);
if (dt->advance)
mask |= set_string (&block, &post_block, var, IOPARM_dt_advance,
dt->advance);
if (dt->format_expr)
mask |= set_string (&block, &post_end_block, var, IOPARM_dt_format,
dt->format_expr);
if (dt->format_label)
{
if (dt->format_label == &format_asterisk)
mask |= IOPARM_dt_list_format;
else
mask |= set_string (&block, &post_block, var, IOPARM_dt_format,
dt->format_label->format);
}
if (dt->size)
mask |= set_parameter_ref (&block, &post_end_block, var,
IOPARM_dt_size, dt->size);
if (dt->namelist)
{
if (dt->format_expr || dt->format_label)
gfc_internal_error ("build_dt: format with namelist");
nmlname = gfc_get_character_expr (gfc_default_character_kind, NULL,
dt->namelist->name,
strlen (dt->namelist->name));
mask |= set_string (&block, &post_block, var, IOPARM_dt_namelist_name,
nmlname);
if (last_dt == READ)
mask |= IOPARM_dt_namelist_read_mode;
set_parameter_const (&block, var, IOPARM_common_flags, mask);
dt_parm = var;
for (nml = dt->namelist->namelist; nml; nml = nml->next)
transfer_namelist_element (&block, nml->sym->name, nml->sym,
NULL, NULL_TREE);
}
else
set_parameter_const (&block, var, IOPARM_common_flags, mask);
if (dt->io_unit && dt->io_unit->ts.type == BT_INTEGER)
set_parameter_value (&block, var, IOPARM_common_unit, dt->io_unit);
}
else
set_parameter_const (&block, var, IOPARM_common_flags, mask);
tmp = gfc_build_addr_expr (NULL_TREE, var);
tmp = build_call_expr_loc (UNKNOWN_LOCATION,
function, 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &post_block);
dt_parm = var;
dt_post_end_block = &post_end_block;
/* Set implied do loop exit condition. */
if (last_dt == READ || last_dt == WRITE)
{
gfc_st_parameter_field *p = &st_parameter_field[IOPARM_common_flags];
tmp = fold_build3_loc (input_location, COMPONENT_REF,
st_parameter[IOPARM_ptype_common].type,
dt_parm, TYPE_FIELDS (TREE_TYPE (dt_parm)),
NULL_TREE);
tmp = fold_build3_loc (input_location, COMPONENT_REF,
TREE_TYPE (p->field), tmp, p->field, NULL_TREE);
tmp = fold_build2_loc (input_location, BIT_AND_EXPR, TREE_TYPE (tmp),
tmp, build_int_cst (TREE_TYPE (tmp),
IOPARM_common_libreturn_mask));
}
else /* IOLENGTH */
tmp = NULL_TREE;
gfc_add_expr_to_block (&block, gfc_trans_code_cond (code->block->next, tmp));
gfc_add_block_to_block (&block, &post_iu_block);
dt_parm = NULL;
dt_post_end_block = NULL;
return gfc_finish_block (&block);
}
/* Translate the IOLENGTH form of an INQUIRE statement. We treat
this as a third sort of data transfer statement, except that
lengths are summed instead of actually transferring any data. */
tree
gfc_trans_iolength (gfc_code * code)
{
last_dt = IOLENGTH;
return build_dt (iocall[IOCALL_IOLENGTH], code);
}
/* Translate a READ statement. */
tree
gfc_trans_read (gfc_code * code)
{
last_dt = READ;
return build_dt (iocall[IOCALL_READ], code);
}
/* Translate a WRITE statement */
tree
gfc_trans_write (gfc_code * code)
{
last_dt = WRITE;
return build_dt (iocall[IOCALL_WRITE], code);
}
/* Finish a data transfer statement. */
tree
gfc_trans_dt_end (gfc_code * code)
{
tree function, tmp;
stmtblock_t block;
gfc_init_block (&block);
switch (last_dt)
{
case READ:
function = iocall[IOCALL_READ_DONE];
break;
case WRITE:
function = iocall[IOCALL_WRITE_DONE];
break;
case IOLENGTH:
function = iocall[IOCALL_IOLENGTH_DONE];
break;
default:
gcc_unreachable ();
}
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
tmp = build_call_expr_loc (input_location,
function, 1, tmp);
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, dt_post_end_block);
gfc_init_block (dt_post_end_block);
if (last_dt != IOLENGTH)
{
gcc_assert (code->ext.dt != NULL);
io_result (&block, dt_parm, code->ext.dt->err,
code->ext.dt->end, code->ext.dt->eor);
}
return gfc_finish_block (&block);
}
static void
transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code);
/* Given an array field in a derived type variable, generate the code
for the loop that iterates over array elements, and the code that
accesses those array elements. Use transfer_expr to generate code
for transferring that element. Because elements may also be
derived types, transfer_expr and transfer_array_component are mutually
recursive. */
static tree
transfer_array_component (tree expr, gfc_component * cm, locus * where)
{
tree tmp;
stmtblock_t body;
stmtblock_t block;
gfc_loopinfo loop;
int n;
gfc_ss *ss;
gfc_se se;
gfc_array_info *ss_array;
gfc_start_block (&block);
gfc_init_se (&se, NULL);
/* Create and initialize Scalarization Status. Unlike in
gfc_trans_transfer, we can't simply use gfc_walk_expr to take
care of this task, because we don't have a gfc_expr at hand.
Build one manually, as in gfc_trans_subarray_assign. */
ss = gfc_get_array_ss (gfc_ss_terminator, NULL, cm->as->rank,
GFC_SS_COMPONENT);
ss_array = &ss->info->data.array;
ss_array->shape = gfc_get_shape (cm->as->rank);
ss_array->descriptor = expr;
ss_array->data = gfc_conv_array_data (expr);
ss_array->offset = gfc_conv_array_offset (expr);
for (n = 0; n < cm->as->rank; n++)
{
ss_array->start[n] = gfc_conv_array_lbound (expr, n);
ss_array->stride[n] = gfc_index_one_node;
mpz_init (ss_array->shape[n]);
mpz_sub (ss_array->shape[n], cm->as->upper[n]->value.integer,
cm->as->lower[n]->value.integer);
mpz_add_ui (ss_array->shape[n], ss_array->shape[n], 1);
}
/* Once we got ss, we use scalarizer to create the loop. */
gfc_init_loopinfo (&loop);
gfc_add_ss_to_loop (&loop, ss);
gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop, where);
gfc_mark_ss_chain_used (ss, 1);
gfc_start_scalarized_body (&loop, &body);
gfc_copy_loopinfo_to_se (&se, &loop);
se.ss = ss;
/* gfc_conv_tmp_array_ref assumes that se.expr contains the array. */
se.expr = expr;
gfc_conv_tmp_array_ref (&se);
/* Now se.expr contains an element of the array. Take the address and pass
it to the IO routines. */
tmp = gfc_build_addr_expr (NULL_TREE, se.expr);
transfer_expr (&se, &cm->ts, tmp, NULL);
/* We are done now with the loop body. Wrap up the scalarizer and
return. */
gfc_add_block_to_block (&body, &se.pre);
gfc_add_block_to_block (&body, &se.post);
gfc_trans_scalarizing_loops (&loop, &body);
gfc_add_block_to_block (&block, &loop.pre);
gfc_add_block_to_block (&block, &loop.post);
gcc_assert (ss_array->shape != NULL);
gfc_free_shape (&ss_array->shape, cm->as->rank);
gfc_cleanup_loop (&loop);
return gfc_finish_block (&block);
}
/* Generate the call for a scalar transfer node. */
static void
transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code)
{
tree tmp, function, arg2, arg3, field, expr;
gfc_component *c;
int kind;
/* It is possible to get a C_NULL_PTR or C_NULL_FUNPTR expression here if
the user says something like: print *, 'c_null_ptr: ', c_null_ptr
We need to translate the expression to a constant if it's either
C_NULL_PTR or C_NULL_FUNPTR. We could also get a user variable of
type C_PTR or C_FUNPTR, in which case the ts->type may no longer be
BT_DERIVED (could have been changed by gfc_conv_expr). */
if ((ts->type == BT_DERIVED || ts->type == BT_INTEGER)
&& ts->u.derived != NULL
&& (ts->is_iso_c == 1 || ts->u.derived->ts.is_iso_c == 1))
{
/* C_PTR and C_FUNPTR have private components which means they can not
be printed. However, if -std=gnu and not -pedantic, allow
the component to be printed to help debugging. */
if (gfc_notification_std (GFC_STD_GNU) != SILENT)
{
gfc_error_now ("Derived type '%s' at %L has PRIVATE components",
ts->u.derived->name, code != NULL ? &(code->loc) :
&gfc_current_locus);
return;
}
ts->type = ts->u.derived->ts.type;
ts->kind = ts->u.derived->ts.kind;
ts->f90_type = ts->u.derived->ts.f90_type;
}
kind = ts->kind;
function = NULL;
arg2 = NULL;
arg3 = NULL;
switch (ts->type)
{
case BT_INTEGER:
arg2 = build_int_cst (integer_type_node, kind);
if (last_dt == READ)
function = iocall[IOCALL_X_INTEGER];
else
function = iocall[IOCALL_X_INTEGER_WRITE];
break;
case BT_REAL:
arg2 = build_int_cst (integer_type_node, kind);
if (last_dt == READ)
{
if (gfc_real16_is_float128 && ts->kind == 16)
function = iocall[IOCALL_X_REAL128];
else
function = iocall[IOCALL_X_REAL];
}
else
{
if (gfc_real16_is_float128 && ts->kind == 16)
function = iocall[IOCALL_X_REAL128_WRITE];
else
function = iocall[IOCALL_X_REAL_WRITE];
}
break;
case BT_COMPLEX:
arg2 = build_int_cst (integer_type_node, kind);
if (last_dt == READ)
{
if (gfc_real16_is_float128 && ts->kind == 16)
function = iocall[IOCALL_X_COMPLEX128];
else
function = iocall[IOCALL_X_COMPLEX];
}
else
{
if (gfc_real16_is_float128 && ts->kind == 16)
function = iocall[IOCALL_X_COMPLEX128_WRITE];
else
function = iocall[IOCALL_X_COMPLEX_WRITE];
}
break;
case BT_LOGICAL:
arg2 = build_int_cst (integer_type_node, kind);
if (last_dt == READ)
function = iocall[IOCALL_X_LOGICAL];
else
function = iocall[IOCALL_X_LOGICAL_WRITE];
break;
case BT_CHARACTER:
if (kind == 4)
{
if (se->string_length)
arg2 = se->string_length;
else
{
tmp = build_fold_indirect_ref_loc (input_location,
addr_expr);
gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE);
arg2 = TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (tmp)));
arg2 = fold_convert (gfc_charlen_type_node, arg2);
}
arg3 = build_int_cst (integer_type_node, kind);
if (last_dt == READ)
function = iocall[IOCALL_X_CHARACTER_WIDE];
else
function = iocall[IOCALL_X_CHARACTER_WIDE_WRITE];
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
tmp = build_call_expr_loc (input_location,
function, 4, tmp, addr_expr, arg2, arg3);
gfc_add_expr_to_block (&se->pre, tmp);
gfc_add_block_to_block (&se->pre, &se->post);
return;
}
/* Fall through. */
case BT_HOLLERITH:
if (se->string_length)
arg2 = se->string_length;
else
{
tmp = build_fold_indirect_ref_loc (input_location,
addr_expr);
gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE);
arg2 = TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (tmp)));
}
if (last_dt == READ)
function = iocall[IOCALL_X_CHARACTER];
else
function = iocall[IOCALL_X_CHARACTER_WRITE];
break;
case BT_DERIVED:
if (ts->u.derived->components == NULL)
return;
/* Recurse into the elements of the derived type. */
expr = gfc_evaluate_now (addr_expr, &se->pre);
expr = build_fold_indirect_ref_loc (input_location,
expr);
for (c = ts->u.derived->components; c; c = c->next)
{
field = c->backend_decl;
gcc_assert (field && TREE_CODE (field) == FIELD_DECL);
tmp = fold_build3_loc (UNKNOWN_LOCATION,
COMPONENT_REF, TREE_TYPE (field),
expr, field, NULL_TREE);
if (c->attr.dimension)
{
tmp = transfer_array_component (tmp, c, & code->loc);
gfc_add_expr_to_block (&se->pre, tmp);
}
else
{
if (!c->attr.pointer)
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
transfer_expr (se, &c->ts, tmp, code);
}
}
return;
default:
internal_error ("Bad IO basetype (%d)", ts->type);
}
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
tmp = build_call_expr_loc (input_location,
function, 3, tmp, addr_expr, arg2);
gfc_add_expr_to_block (&se->pre, tmp);
gfc_add_block_to_block (&se->pre, &se->post);
}
/* Generate a call to pass an array descriptor to the IO library. The
array should be of one of the intrinsic types. */
static void
transfer_array_desc (gfc_se * se, gfc_typespec * ts, tree addr_expr)
{
tree tmp, charlen_arg, kind_arg, io_call;
if (ts->type == BT_CHARACTER)
charlen_arg = se->string_length;
else
charlen_arg = build_int_cst (gfc_charlen_type_node, 0);
kind_arg = build_int_cst (integer_type_node, ts->kind);
tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
if (last_dt == READ)
io_call = iocall[IOCALL_X_ARRAY];
else
io_call = iocall[IOCALL_X_ARRAY_WRITE];
tmp = build_call_expr_loc (UNKNOWN_LOCATION,
io_call, 4,
tmp, addr_expr, kind_arg, charlen_arg);
gfc_add_expr_to_block (&se->pre, tmp);
gfc_add_block_to_block (&se->pre, &se->post);
}
/* gfc_trans_transfer()-- Translate a TRANSFER code node */
tree
gfc_trans_transfer (gfc_code * code)
{
stmtblock_t block, body;
gfc_loopinfo loop;
gfc_expr *expr;
gfc_ref *ref;
gfc_ss *ss;
gfc_se se;
tree tmp;
int n;
gfc_start_block (&block);
gfc_init_block (&body);
expr = code->expr1;
ref = NULL;
gfc_init_se (&se, NULL);
if (expr->rank == 0)
{
/* Transfer a scalar value. */
gfc_conv_expr_reference (&se, expr);
transfer_expr (&se, &expr->ts, se.expr, code);
}
else
{
/* Transfer an array. If it is an array of an intrinsic
type, pass the descriptor to the library. Otherwise
scalarize the transfer. */
if (expr->ref && !gfc_is_proc_ptr_comp (expr))
{
for (ref = expr->ref; ref && ref->type != REF_ARRAY;
ref = ref->next);
gcc_assert (ref && ref->type == REF_ARRAY);
}
if (expr->ts.type != BT_DERIVED
&& ref && ref->next == NULL
&& !is_subref_array (expr))
{
bool seen_vector = false;
if (ref && ref->u.ar.type == AR_SECTION)
{
for (n = 0; n < ref->u.ar.dimen; n++)
if (ref->u.ar.dimen_type[n] == DIMEN_VECTOR)
seen_vector = true;
}
if (seen_vector && last_dt == READ)
{
/* Create a temp, read to that and copy it back. */
gfc_conv_subref_array_arg (&se, expr, 0, INTENT_OUT, false);
tmp = se.expr;
}
else
{
/* Get the descriptor. */
gfc_conv_expr_descriptor (&se, expr);
tmp = gfc_build_addr_expr (NULL_TREE, se.expr);
}
transfer_array_desc (&se, &expr->ts, tmp);
goto finish_block_label;
}
/* Initialize the scalarizer. */
ss = gfc_walk_expr (expr);
gfc_init_loopinfo (&loop);
gfc_add_ss_to_loop (&loop, ss);
/* Initialize the loop. */
gfc_conv_ss_startstride (&loop);
gfc_conv_loop_setup (&loop, &code->expr1->where);
/* The main loop body. */
gfc_mark_ss_chain_used (ss, 1);
gfc_start_scalarized_body (&loop, &body);
gfc_copy_loopinfo_to_se (&se, &loop);
se.ss = ss;
gfc_conv_expr_reference (&se, expr);
transfer_expr (&se, &expr->ts, se.expr, code);
}
finish_block_label:
gfc_add_block_to_block (&body, &se.pre);
gfc_add_block_to_block (&body, &se.post);
if (se.ss == NULL)
tmp = gfc_finish_block (&body);
else
{
gcc_assert (expr->rank != 0);
gcc_assert (se.ss == gfc_ss_terminator);
gfc_trans_scalarizing_loops (&loop, &body);
gfc_add_block_to_block (&loop.pre, &loop.post);
tmp = gfc_finish_block (&loop.pre);
gfc_cleanup_loop (&loop);
}
gfc_add_expr_to_block (&block, tmp);
return gfc_finish_block (&block);
}
#include "gt-fortran-trans-io.h"
|
mm120/gcc-vc4
|
gcc/fortran/trans-io.c
|
C
|
gpl-2.0
| 67,074 |
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Cache management form page
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <[email protected]>
*/
class Mage_Adminhtml_Block_Extensions_Mass_Install extends Mage_Adminhtml_Block_Widget_Form
{
public function initForm()
{
$this->setTitle('Install packages');
$this->setTemplate('extensions/mass/install.phtml');
return $this;
}
public function getUpgradeAllButtonHtml()
{
$html = '';
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
->setClass('add')->setLabel($this->__('Upgrade all packages'))
->setOnClick("upgradeAll()")
->toHtml();
return $html;
}
public function getBackButtonHtml()
{
$html = '';
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
->setClass('back')->setLabel($this->__('Back to local packages'))
->setOnClick("setLocation('" . $this->getUrl('*/extensions_local') . "')")
->toHtml();
return $html;
}
}
|
tonio-44/tikflak
|
shop/app/code/core/Mage/Adminhtml/Block/Extensions/Mass/Install.php
|
PHP
|
gpl-2.0
| 2,112 |
<?php
return [
/**
* ---------------------------------------
* Partial to render each comment
* ---------------------------------------
*/
'itemTemplate' => 'partials.comments.item'
];
|
bruno-barros/w.eloquent
|
src/themes/base/app/config/comments.php
|
PHP
|
gpl-2.0
| 195 |
<?php
defined('TYPO3_MODE') or die();
if (TYPO3_MODE === 'BE') {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
'tools',
'txdbalM1',
'',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'mod1/',
array(
'script' => '_DISPATCH',
'access' => 'admin',
'name' => 'tools_txdbalM1',
'labels' => array(
'tabs_images' => array(
'tab' => '../Resources/Public/Icons/module-dbal.png',
),
'll_ref' => 'LLL:EXT:dbal/mod1/locallang_mod.xlf',
),
)
);
}
|
Loopshape/Portfolio
|
typo3_src-7.3.1/typo3/sysext/dbal/ext_tables.php
|
PHP
|
gpl-2.0
| 523 |
/*
* Block driver for media (i.e., flash cards)
*
* Copyright 2002 Hewlett-Packard Company
* Copyright 2005-2008 Pierre Ossman
*
* Use consistent with the GNU GPL is permitted,
* provided that this copyright notice is
* preserved in its entirety in all copies and derived works.
*
* HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
* AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
* FITNESS FOR ANY PARTICULAR PURPOSE.
*
* Many thanks to Alessandro Rubini and Jonathan Corbet!
*
* Author: Andrew Christian
* 28 May 2002
*/
#include <linux/moduleparam.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/hdreg.h>
#include <linux/kdev_t.h>
#include <linux/blkdev.h>
#include <linux/mutex.h>
#include <linux/scatterlist.h>
#include <linux/bitops.h>
#include <linux/string_helpers.h>
#include <linux/delay.h>
#include <linux/capability.h>
#include <linux/compat.h>
#include <linux/pm_runtime.h>
#include <linux/sysfs.h>
#include <linux/mmc/ioctl.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include <asm/uaccess.h>
#include "queue.h"
#include "../core/core.h"
MODULE_ALIAS("mmc:block");
#if defined(CONFIG_MMC_CPRM)
#include "cprmdrv_samsung.h"
#include <linux/ioctl.h>
#define MMC_IOCTL_BASE 0xB3 /* Same as MMC block device major number */
#define MMC_IOCTL_GET_SECTOR_COUNT _IOR(MMC_IOCTL_BASE, 100, int)
#define MMC_IOCTL_GET_SECTOR_SIZE _IOR(MMC_IOCTL_BASE, 101, int)
#define MMC_IOCTL_GET_BLOCK_SIZE _IOR(MMC_IOCTL_BASE, 102, int)
#define MMC_IOCTL_SET_RETRY_AKE_PROCESS _IOR(MMC_IOCTL_BASE, 104, int)
static int cprm_ake_retry_flag;
#endif
#ifdef MODULE_PARAM_PREFIX
#undef MODULE_PARAM_PREFIX
#endif
#define MODULE_PARAM_PREFIX "mmcblk."
#define INAND_CMD38_ARG_EXT_CSD 113
#define INAND_CMD38_ARG_ERASE 0x00
#define INAND_CMD38_ARG_TRIM 0x01
#define INAND_CMD38_ARG_SECERASE 0x80
#define INAND_CMD38_ARG_SECTRIM1 0x81
#define INAND_CMD38_ARG_SECTRIM2 0x88
#define MMC_BLK_TIMEOUT_MS (30 * 1000) /* 30 sec timeout */
#define MMC_SANITIZE_REQ_TIMEOUT 240000 /* msec */
#define mmc_req_rel_wr(req) (((req->cmd_flags & REQ_FUA) || \
(req->cmd_flags & REQ_META)) && \
(rq_data_dir(req) == WRITE))
#define PACKED_CMD_VER 0x01
#define PACKED_CMD_WR 0x02
#define PACKED_TRIGGER_MAX_ELEMENTS 5000
#define MMC_BLK_MAX_RETRIES 5 /* max # of retries before aborting a command */
#define MMC_BLK_UPDATE_STOP_REASON(stats, reason) \
do { \
if (stats->enabled) \
stats->pack_stop_reason[reason]++; \
} while (0)
#define PCKD_TRGR_INIT_MEAN_POTEN 17
#define PCKD_TRGR_POTEN_LOWER_BOUND 5
#define PCKD_TRGR_URGENT_PENALTY 2
#define PCKD_TRGR_LOWER_BOUND 5
#define PCKD_TRGR_PRECISION_MULTIPLIER 100
static DEFINE_MUTEX(block_mutex);
/*
* The defaults come from config options but can be overriden by module
* or bootarg options.
*/
static int perdev_minors = CONFIG_MMC_BLOCK_MINORS;
/*
* We've only got one major, so number of mmcblk devices is
* limited to 256 / number of minors per device.
*/
static int max_devices;
/* 256 minors, so at most 256 separate devices */
static DECLARE_BITMAP(dev_use, 256);
static DECLARE_BITMAP(name_use, 256);
/*
* There is one mmc_blk_data per slot.
*/
struct mmc_blk_data {
spinlock_t lock;
struct gendisk *disk;
struct mmc_queue queue;
struct list_head part;
unsigned int flags;
#define MMC_BLK_CMD23 (1 << 0) /* Can do SET_BLOCK_COUNT for multiblock */
#define MMC_BLK_REL_WR (1 << 1) /* MMC Reliable write support */
unsigned int usage;
unsigned int read_only;
unsigned int part_type;
unsigned int name_idx;
unsigned int reset_done;
#define MMC_BLK_READ BIT(0)
#define MMC_BLK_WRITE BIT(1)
#define MMC_BLK_DISCARD BIT(2)
#define MMC_BLK_SECDISCARD BIT(3)
/*
* Only set in main mmc_blk_data associated
* with mmc_card with mmc_set_drvdata, and keeps
* track of the current selected device partition.
*/
unsigned int part_curr;
struct device_attribute force_ro;
struct device_attribute power_ro_lock;
struct device_attribute num_wr_reqs_to_start_packing;
struct device_attribute bkops_check_threshold;
struct device_attribute no_pack_for_random;
int area_type;
};
static DEFINE_MUTEX(open_lock);
enum {
MMC_PACKED_N_IDX = -1,
MMC_PACKED_N_ZERO,
MMC_PACKED_N_SINGLE,
};
module_param(perdev_minors, int, 0444);
MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device");
static inline int mmc_blk_part_switch(struct mmc_card *card,
struct mmc_blk_data *md);
static int get_card_status(struct mmc_card *card, u32 *status, int retries);
static inline void mmc_blk_clear_packed(struct mmc_queue_req *mqrq)
{
mqrq->packed_cmd = MMC_PACKED_NONE;
mqrq->packed_num = MMC_PACKED_N_ZERO;
}
static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
{
struct mmc_blk_data *md;
mutex_lock(&open_lock);
md = disk->private_data;
if (md && md->usage == 0)
md = NULL;
if (md)
md->usage++;
mutex_unlock(&open_lock);
return md;
}
static inline int mmc_get_devidx(struct gendisk *disk)
{
int devidx = disk->first_minor / perdev_minors;
return devidx;
}
static void mmc_blk_put(struct mmc_blk_data *md)
{
mutex_lock(&open_lock);
md->usage--;
if (md->usage == 0) {
int devidx = mmc_get_devidx(md->disk);
blk_cleanup_queue(md->queue.queue);
__clear_bit(devidx, dev_use);
put_disk(md->disk);
kfree(md);
}
mutex_unlock(&open_lock);
}
static ssize_t power_ro_lock_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int ret;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
struct mmc_card *card;
int locked = 0;
if (!md)
return -EINVAL;
card = md->queue.card;
if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PERM_WP_EN)
locked = 2;
else if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_EN)
locked = 1;
ret = snprintf(buf, PAGE_SIZE, "%d\n", locked);
return ret;
}
static ssize_t power_ro_lock_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int ret;
struct mmc_blk_data *md, *part_md;
struct mmc_card *card;
unsigned long set;
if (kstrtoul(buf, 0, &set))
return -EINVAL;
if (set != 1)
return count;
md = mmc_blk_get(dev_to_disk(dev));
if (!md)
return -EINVAL;
card = md->queue.card;
mmc_rpm_hold(card->host, &card->dev);
mmc_claim_host(card->host);
ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
card->ext_csd.boot_ro_lock |
EXT_CSD_BOOT_WP_B_PWR_WP_EN,
card->ext_csd.part_time);
if (ret)
pr_err("%s: Locking boot partition ro until next power on failed: %d\n", md->disk->disk_name, ret);
else
card->ext_csd.boot_ro_lock |= EXT_CSD_BOOT_WP_B_PWR_WP_EN;
mmc_release_host(card->host);
mmc_rpm_release(card->host, &card->dev);
if (!ret) {
pr_info("%s: Locking boot partition ro until next power on\n",
md->disk->disk_name);
set_disk_ro(md->disk, 1);
list_for_each_entry(part_md, &md->part, part)
if (part_md->area_type == MMC_BLK_DATA_AREA_BOOT) {
pr_info("%s: Locking boot partition ro until next power on\n", part_md->disk->disk_name);
set_disk_ro(part_md->disk, 1);
}
}
mmc_blk_put(md);
return count;
}
static ssize_t force_ro_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
int ret;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
if (!md)
return -EINVAL;
ret = snprintf(buf, PAGE_SIZE, "%d",
get_disk_ro(dev_to_disk(dev)) ^
md->read_only);
mmc_blk_put(md);
return ret;
}
static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int ret;
char *end;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
unsigned long set = simple_strtoul(buf, &end, 0);
if (!md)
return -EINVAL;
if (end == buf) {
ret = -EINVAL;
goto out;
}
set_disk_ro(dev_to_disk(dev), set || md->read_only);
ret = count;
out:
mmc_blk_put(md);
return ret;
}
static ssize_t
num_wr_reqs_to_start_packing_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
int num_wr_reqs_to_start_packing;
int ret;
if (!md)
return -EINVAL;
num_wr_reqs_to_start_packing = md->queue.num_wr_reqs_to_start_packing;
ret = snprintf(buf, PAGE_SIZE, "%d\n", num_wr_reqs_to_start_packing);
mmc_blk_put(md);
return ret;
}
static ssize_t
num_wr_reqs_to_start_packing_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int value;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
struct mmc_card *card;
int ret = count;
if (!md)
return -EINVAL;
card = md->queue.card;
if (!card) {
ret = -EINVAL;
goto exit;
}
sscanf(buf, "%d", &value);
if (value >= 0) {
md->queue.num_wr_reqs_to_start_packing =
min_t(int, value, (int)card->ext_csd.max_packed_writes);
pr_debug("%s: trigger to pack: new value = %d",
mmc_hostname(card->host),
md->queue.num_wr_reqs_to_start_packing);
} else {
pr_err("%s: value %d is not valid. old value remains = %d",
mmc_hostname(card->host), value,
md->queue.num_wr_reqs_to_start_packing);
ret = -EINVAL;
}
exit:
mmc_blk_put(md);
return ret;
}
static ssize_t
bkops_check_threshold_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
struct mmc_card *card;
int ret;
if (!md)
return -EINVAL;
card = md->queue.card;
if (!card)
ret = -EINVAL;
else
ret = snprintf(buf, PAGE_SIZE, "%d\n",
card->bkops_info.size_percentage_to_queue_delayed_work);
mmc_blk_put(md);
return ret;
}
static ssize_t
bkops_check_threshold_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int value;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
struct mmc_card *card;
unsigned int card_size;
int ret = count;
if (!md)
return -EINVAL;
card = md->queue.card;
if (!card) {
ret = -EINVAL;
goto exit;
}
sscanf(buf, "%d", &value);
if ((value <= 0) || (value >= 100)) {
ret = -EINVAL;
goto exit;
}
card_size = (unsigned int)get_capacity(md->disk);
if (card_size <= 0) {
ret = -EINVAL;
goto exit;
}
card->bkops_info.size_percentage_to_queue_delayed_work = value;
card->bkops_info.min_sectors_to_queue_delayed_work =
(card_size * value) / 100;
pr_debug("%s: size_percentage = %d, min_sectors = %d",
mmc_hostname(card->host),
card->bkops_info.size_percentage_to_queue_delayed_work,
card->bkops_info.min_sectors_to_queue_delayed_work);
exit:
mmc_blk_put(md);
return count;
}
static ssize_t
no_pack_for_random_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
int ret;
if (!md)
return -EINVAL;
ret = snprintf(buf, PAGE_SIZE, "%d\n", md->queue.no_pack_for_random);
mmc_blk_put(md);
return ret;
}
static ssize_t
no_pack_for_random_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int value;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
struct mmc_card *card;
int ret = count;
if (!md)
return -EINVAL;
card = md->queue.card;
if (!card) {
ret = -EINVAL;
goto exit;
}
sscanf(buf, "%d", &value);
if (value < 0) {
pr_err("%s: value %d is not valid. old value remains = %d",
mmc_hostname(card->host), value,
md->queue.no_pack_for_random);
ret = -EINVAL;
goto exit;
}
md->queue.no_pack_for_random = (value > 0) ? true : false;
pr_debug("%s: no_pack_for_random: new value = %d",
mmc_hostname(card->host),
md->queue.no_pack_for_random);
exit:
mmc_blk_put(md);
return ret;
}
static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
{
struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
int ret = -ENXIO;
mutex_lock(&block_mutex);
if (md) {
if (md->usage == 2)
check_disk_change(bdev);
ret = 0;
if ((mode & FMODE_WRITE) && md->read_only) {
mmc_blk_put(md);
ret = -EROFS;
}
}
mutex_unlock(&block_mutex);
return ret;
}
static int mmc_blk_release(struct gendisk *disk, fmode_t mode)
{
struct mmc_blk_data *md = disk->private_data;
mutex_lock(&block_mutex);
mmc_blk_put(md);
mutex_unlock(&block_mutex);
return 0;
}
static int
mmc_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
{
geo->cylinders = get_capacity(bdev->bd_disk) / (4 * 16);
geo->heads = 4;
geo->sectors = 16;
return 0;
}
struct mmc_blk_ioc_data {
struct mmc_ioc_cmd ic;
unsigned char *buf;
u64 buf_bytes;
};
static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
struct mmc_ioc_cmd __user *user)
{
struct mmc_blk_ioc_data *idata;
int err;
idata = kzalloc(sizeof(*idata), GFP_KERNEL);
if (!idata) {
err = -ENOMEM;
goto out;
}
if (copy_from_user(&idata->ic, user, sizeof(idata->ic))) {
err = -EFAULT;
goto idata_err;
}
idata->buf_bytes = (u64) idata->ic.blksz * idata->ic.blocks;
if (idata->buf_bytes > MMC_IOC_MAX_BYTES) {
err = -EOVERFLOW;
goto idata_err;
}
if (!idata->buf_bytes)
return idata;
idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL);
if (!idata->buf) {
err = -ENOMEM;
goto idata_err;
}
if (copy_from_user(idata->buf, (void __user *)(unsigned long)
idata->ic.data_ptr, idata->buf_bytes)) {
err = -EFAULT;
goto copy_err;
}
return idata;
copy_err:
kfree(idata->buf);
idata_err:
kfree(idata);
out:
return ERR_PTR(err);
}
struct scatterlist *mmc_blk_get_sg(struct mmc_card *card,
unsigned char *buf, int *sg_len, int size)
{
struct scatterlist *sg;
struct scatterlist *sl;
int total_sec_cnt, sec_cnt;
int max_seg_size, len;
total_sec_cnt = size;
max_seg_size = card->host->max_seg_size;
len = (size - 1 + max_seg_size) / max_seg_size;
sl = kmalloc(sizeof(struct scatterlist) * len, GFP_KERNEL);
if (!sl) {
return NULL;
}
sg = (struct scatterlist *)sl;
sg_init_table(sg, len);
while (total_sec_cnt) {
if (total_sec_cnt < max_seg_size)
sec_cnt = total_sec_cnt;
else
sec_cnt = max_seg_size;
sg_set_page(sg, virt_to_page(buf), sec_cnt, offset_in_page(buf));
buf = buf + sec_cnt;
total_sec_cnt = total_sec_cnt - sec_cnt;
if (total_sec_cnt == 0)
break;
sg = sg_next(sg);
}
if (sg)
sg_mark_end(sg);
*sg_len = len;
return sl;
}
static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status,
u32 retries_max)
{
int err;
u32 retry_count = 0;
if (!status || !retries_max)
return -EINVAL;
do {
err = get_card_status(card, status, 5);
if (err)
break;
if (!R1_STATUS(*status) &&
(R1_CURRENT_STATE(*status) != R1_STATE_PRG))
break; /* RPMB programming operation complete */
/*
* Rechedule to give the MMC device a chance to continue
* processing the previous command without being polled too
* frequently.
*/
usleep_range(1000, 5000);
} while (++retry_count < retries_max);
if (retry_count == retries_max)
err = -EPERM;
return err;
}
static int mmc_blk_ioctl_cmd(struct block_device *bdev,
struct mmc_ioc_cmd __user *ic_ptr)
{
struct mmc_blk_ioc_data *idata;
struct mmc_blk_data *md;
struct mmc_card *card;
struct mmc_command cmd = {0};
struct mmc_data data = {0};
struct mmc_request mrq = {NULL};
struct scatterlist *sg = 0;
int err = 0;
int is_rpmb = false;
u32 status = 0;
/*
* The caller must have CAP_SYS_RAWIO, and must be calling this on the
* whole block device, not on a partition. This prevents overspray
* between sibling partitions.
*/
if ((!capable(CAP_SYS_RAWIO)) || (bdev != bdev->bd_contains))
return -EPERM;
idata = mmc_blk_ioctl_copy_from_user(ic_ptr);
if (IS_ERR(idata))
return PTR_ERR(idata);
md = mmc_blk_get(bdev->bd_disk);
if (!md) {
err = -EINVAL;
goto blk_err;
}
if (md->area_type & MMC_BLK_DATA_AREA_RPMB) {
is_rpmb = true;
}
card = md->queue.card;
if (IS_ERR(card)) {
err = PTR_ERR(card);
goto cmd_done;
}
cmd.opcode = idata->ic.opcode;
cmd.arg = idata->ic.arg;
cmd.flags = idata->ic.flags;
if (idata->buf_bytes) {
int len;
data.blksz = idata->ic.blksz;
data.blocks = idata->ic.blocks;
sg = mmc_blk_get_sg(card, idata->buf, &len, idata->buf_bytes);
data.sg = sg;
data.sg_len = len;
if (idata->ic.write_flag)
data.flags = MMC_DATA_WRITE;
else
data.flags = MMC_DATA_READ;
/* data.flags must already be set before doing this. */
mmc_set_data_timeout(&data, card);
/* Allow overriding the timeout_ns for empirical tuning. */
if (idata->ic.data_timeout_ns)
data.timeout_ns = idata->ic.data_timeout_ns;
if ((cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
/*
* Pretend this is a data transfer and rely on the
* host driver to compute timeout. When all host
* drivers support cmd.cmd_timeout for R1B, this
* can be changed to:
*
* mrq.data = NULL;
* cmd.cmd_timeout = idata->ic.cmd_timeout_ms;
*/
data.timeout_ns = idata->ic.cmd_timeout_ms * 1000000;
}
mrq.data = &data;
}
mrq.cmd = &cmd;
mmc_rpm_hold(card->host, &card->dev);
mmc_claim_host(card->host);
err = mmc_blk_part_switch(card, md);
if (err)
goto cmd_rel_host;
if (idata->ic.is_acmd) {
err = mmc_app_cmd(card->host, card);
if (err)
goto cmd_rel_host;
}
if (is_rpmb) {
err = mmc_set_blockcount(card, data.blocks,
idata->ic.write_flag & (1 << 31));
if (err)
goto cmd_rel_host;
}
mmc_wait_for_req(card->host, &mrq);
if (cmd.error) {
dev_err(mmc_dev(card->host), "%s: cmd error %d\n",
__func__, cmd.error);
err = cmd.error;
goto cmd_rel_host;
}
if (data.error) {
dev_err(mmc_dev(card->host), "%s: data error %d\n",
__func__, data.error);
err = data.error;
goto cmd_rel_host;
}
/*
* According to the SD specs, some commands require a delay after
* issuing the command.
*/
if (idata->ic.postsleep_min_us)
usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
if (copy_to_user(&(ic_ptr->response), cmd.resp, sizeof(cmd.resp))) {
err = -EFAULT;
goto cmd_rel_host;
}
if (!idata->ic.write_flag) {
if (copy_to_user((void __user *)(unsigned long) idata->ic.data_ptr,
idata->buf, idata->buf_bytes)) {
err = -EFAULT;
goto cmd_rel_host;
}
}
if (is_rpmb) {
/*
* Ensure RPMB command has completed by polling CMD13
* "Send Status".
*/
err = ioctl_rpmb_card_status_poll(card, &status, 5);
if (err)
dev_err(mmc_dev(card->host), "%s: Card Status=0x%08X, error %d\n", __func__, status, err);
}
cmd_rel_host:
mmc_release_host(card->host);
mmc_rpm_release(card->host, &card->dev);
cmd_done:
mmc_blk_put(md);
blk_err:
if (sg)
kfree(sg);
kfree(idata->buf);
kfree(idata);
return err;
}
struct mmc_blk_ioc_rpmb_data {
struct mmc_blk_ioc_data *data[MMC_IOC_MAX_RPMB_CMD];
};
static struct mmc_blk_ioc_rpmb_data *mmc_blk_ioctl_rpmb_copy_from_user(
struct mmc_ioc_rpmb __user *user)
{
struct mmc_blk_ioc_rpmb_data *idata;
int err, i;
idata = kzalloc(sizeof(*idata), GFP_KERNEL);
if (!idata) {
err = -ENOMEM;
goto out;
}
for (i = 0; i < MMC_IOC_MAX_RPMB_CMD; i++) {
idata->data[i] = mmc_blk_ioctl_copy_from_user(&(user->cmds[i]));
if (IS_ERR(idata->data[i])) {
err = PTR_ERR(idata->data[i]);
goto copy_err;
}
}
return idata;
copy_err:
while (--i >= 0) {
kfree(idata->data[i]->buf);
kfree(idata->data[i]);
}
kfree(idata);
out:
return ERR_PTR(err);
}
static int mmc_blk_ioctl_rpmb_cmd(struct block_device *bdev,
struct mmc_ioc_rpmb __user *ic_ptr)
{
struct mmc_blk_ioc_rpmb_data *idata;
struct mmc_blk_data *md;
struct mmc_card *card;
struct mmc_command cmd = {0};
struct mmc_data data = {0};
struct mmc_request mrq = {NULL};
struct scatterlist sg;
int err = 0, i = 0;
u32 status = 0;
/* The caller must have CAP_SYS_RAWIO */
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
md = mmc_blk_get(bdev->bd_disk);
/* make sure this is a rpmb partition */
if ((!md) || (!(md->area_type & MMC_BLK_DATA_AREA_RPMB))) {
err = -EINVAL;
return err;
}
idata = mmc_blk_ioctl_rpmb_copy_from_user(ic_ptr);
if (IS_ERR(idata)) {
err = PTR_ERR(idata);
goto cmd_done;
}
card = md->queue.card;
if (IS_ERR(card)) {
err = PTR_ERR(card);
goto idata_free;
}
mmc_rpm_hold(card->host, &card->dev);
mmc_claim_host(card->host);
err = mmc_blk_part_switch(card, md);
if (err)
goto cmd_rel_host;
for (i = 0; i < MMC_IOC_MAX_RPMB_CMD; i++) {
struct mmc_blk_ioc_data *curr_data;
struct mmc_ioc_cmd *curr_cmd;
curr_data = idata->data[i];
curr_cmd = &curr_data->ic;
if (!curr_cmd->opcode)
break;
cmd.opcode = curr_cmd->opcode;
cmd.arg = curr_cmd->arg;
cmd.flags = curr_cmd->flags;
if (curr_data->buf_bytes) {
data.sg = &sg;
data.sg_len = 1;
data.blksz = curr_cmd->blksz;
data.blocks = curr_cmd->blocks;
sg_init_one(data.sg, curr_data->buf,
curr_data->buf_bytes);
if (curr_cmd->write_flag)
data.flags = MMC_DATA_WRITE;
else
data.flags = MMC_DATA_READ;
/* data.flags must already be set before doing this. */
mmc_set_data_timeout(&data, card);
/*
* Allow overriding the timeout_ns for empirical tuning.
*/
if (curr_cmd->data_timeout_ns)
data.timeout_ns = curr_cmd->data_timeout_ns;
mrq.data = &data;
}
mrq.cmd = &cmd;
err = mmc_set_blockcount(card, data.blocks,
curr_cmd->write_flag & (1 << 31));
if (err)
goto cmd_rel_host;
mmc_wait_for_req(card->host, &mrq);
if (cmd.error) {
dev_err(mmc_dev(card->host), "%s: cmd error %d\n",
__func__, cmd.error);
err = cmd.error;
goto cmd_rel_host;
}
if (data.error) {
dev_err(mmc_dev(card->host), "%s: data error %d\n",
__func__, data.error);
err = data.error;
goto cmd_rel_host;
}
if (copy_to_user(&(ic_ptr->cmds[i].response), cmd.resp,
sizeof(cmd.resp))) {
err = -EFAULT;
goto cmd_rel_host;
}
if (!curr_cmd->write_flag) {
if (copy_to_user((void __user *)(unsigned long)
curr_cmd->data_ptr,
curr_data->buf,
curr_data->buf_bytes)) {
err = -EFAULT;
goto cmd_rel_host;
}
}
/*
* Ensure RPMB command has completed by polling CMD13
* "Send Status".
*/
err = ioctl_rpmb_card_status_poll(card, &status, 5);
if (err)
dev_err(mmc_dev(card->host),
"%s: Card Status=0x%08X, error %d\n",
__func__, status, err);
}
cmd_rel_host:
mmc_release_host(card->host);
mmc_rpm_release(card->host, &card->dev);
idata_free:
for (i = 0; i < MMC_IOC_MAX_RPMB_CMD; i++) {
kfree(idata->data[i]->buf);
kfree(idata->data[i]);
}
kfree(idata);
cmd_done:
mmc_blk_put(md);
return err;
}
static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
struct mmc_blk_data *md = bdev->bd_disk->private_data;
struct mmc_card *card = md->queue.card;
int ret = -EINVAL;
#if defined(CONFIG_MMC_CPRM)
printk(KERN_DEBUG " %s ], %x ", __func__, cmd);
switch (cmd) {
case MMC_IOCTL_SET_RETRY_AKE_PROCESS:
cprm_ake_retry_flag = 1;
ret = 0;
break;
case MMC_IOCTL_GET_SECTOR_COUNT: {
int size = 0;
size = (int)get_capacity(md->disk) << 9;
printk(KERN_DEBUG "[%s]:MMC_IOCTL_GET_SECTOR_COUNT size = %d\n",
__func__, size);
return copy_to_user((void *)arg, &size, sizeof(u64));
}
break;
case ACMD13:
case ACMD18:
case ACMD25:
case ACMD43:
case ACMD44:
case ACMD45:
case ACMD46:
case ACMD47:
case ACMD48: {
struct cprm_request *req = (struct cprm_request *)arg;
static int i;
static unsigned long temp_arg[16] = {0};
printk(KERN_DEBUG "%s:cmd [%x]\n",
__func__, cmd);
if (cmd == ACMD43) {
printk(KERN_DEBUG"storing acmd43 arg[%d] = %ul\n",
i, (unsigned int)req->arg);
temp_arg[i] = req->arg;
i++;
if (i >= 16) {
printk(KERN_DEBUG"reset acmd43 i = %d\n", i);
i = 0;
}
}
if (cmd == ACMD45 && cprm_ake_retry_flag == 1) {
cprm_ake_retry_flag = 0;
printk(KERN_DEBUG"ACMD45.. I'll call ACMD43 and ACMD44 first\n");
for (i = 0; i < 16; i++) {
printk(KERN_DEBUG"calling ACMD43 with arg[%d] = %ul\n",
i, (unsigned int)temp_arg[i]);
if (stub_sendcmd(card, ACMD43, temp_arg[i],
512, NULL) < 0) {
printk(KERN_DEBUG"error ACMD43 %d\n",
i);
return -EINVAL;
}
}
printk(KERN_DEBUG"calling ACMD44\n");
if (stub_sendcmd(card, ACMD44, 0, 8, NULL) < 0) {
printk(KERN_DEBUG"error in ACMD44 %d\n",
i);
return -EINVAL;
}
}
return stub_sendcmd(card, req->cmd,
req->arg, req->len, req->buff);
}
break;
default:
printk(KERN_DEBUG"%s: Invalid ioctl command\n", __func__);
break;
}
#endif
if (cmd == MMC_IOC_CMD)
ret = mmc_blk_ioctl_cmd(bdev, (struct mmc_ioc_cmd __user *)arg);
else if (cmd == MMC_IOC_RPMB_CMD)
ret = mmc_blk_ioctl_rpmb_cmd(bdev,
(struct mmc_ioc_rpmb __user *)arg);
else if(cmd == MMC_IOC_CLOCK)
{
unsigned int clock = (unsigned int)arg;
if( clock < card->host->f_min )
clock = card->host->f_min;
mmc_set_clock(card->host, clock);
printk(KERN_DEBUG "MMC_IOC_CLOCK : %dhz\n", clock);
ret = 0;
}
else if(cmd == MMC_IOC_BUSWIDTH)
{
unsigned int width = (unsigned int)arg;
mmc_set_bus_width(card->host, width);
printk(KERN_DEBUG "MMC_IOC_BUSWIDTH : %d\n",width);
ret = 0;
}
return ret;
}
#ifdef CONFIG_COMPAT
static int mmc_blk_compat_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
return mmc_blk_ioctl(bdev, mode, cmd, (unsigned long) compat_ptr(arg));
}
#endif
static const struct block_device_operations mmc_bdops = {
.open = mmc_blk_open,
.release = mmc_blk_release,
.getgeo = mmc_blk_getgeo,
.owner = THIS_MODULE,
.ioctl = mmc_blk_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mmc_blk_compat_ioctl,
#endif
};
static inline int mmc_blk_part_switch(struct mmc_card *card,
struct mmc_blk_data *md)
{
int ret;
struct mmc_blk_data *main_md = mmc_get_drvdata(card);
if ((main_md->part_curr == md->part_type) &&
(card->part_curr == md->part_type))
return 0;
if (mmc_card_mmc(card)) {
u8 part_config = card->ext_csd.part_config;
part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK;
part_config |= md->part_type;
ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_PART_CONFIG, part_config,
card->ext_csd.part_time);
if (ret)
return ret;
card->ext_csd.part_config = part_config;
card->part_curr = md->part_type;
}
main_md->part_curr = md->part_type;
return 0;
}
static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
{
int err;
u32 result;
__be32 *blocks;
struct mmc_request mrq = {NULL};
struct mmc_command cmd = {0};
struct mmc_data data = {0};
struct scatterlist sg;
cmd.opcode = MMC_APP_CMD;
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err)
return (u32)-1;
if (!mmc_host_is_spi(card->host) && !(cmd.resp[0] & R1_APP_CMD))
return (u32)-1;
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = SD_APP_SEND_NUM_WR_BLKS;
cmd.arg = 0;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
data.blksz = 4;
data.blocks = 1;
data.flags = MMC_DATA_READ;
data.sg = &sg;
data.sg_len = 1;
mmc_set_data_timeout(&data, card);
mrq.cmd = &cmd;
mrq.data = &data;
blocks = kmalloc(4, GFP_KERNEL);
if (!blocks)
return (u32)-1;
sg_init_one(&sg, blocks, 4);
mmc_wait_for_req(card->host, &mrq);
result = ntohl(*blocks);
kfree(blocks);
if (cmd.error || data.error)
result = (u32)-1;
return result;
}
static int send_stop(struct mmc_card *card, u32 *status)
{
struct mmc_command cmd = {0};
int err;
cmd.opcode = MMC_STOP_TRANSMISSION;
cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 5);
if (err == 0)
*status = cmd.resp[0];
return err;
}
static int get_card_status(struct mmc_card *card, u32 *status, int retries)
{
struct mmc_command cmd = {0};
int err;
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, retries);
if (err == 0)
*status = cmd.resp[0];
return err;
}
#define ERR_NOMEDIUM 3
#define ERR_RETRY 2
#define ERR_ABORT 1
#define ERR_CONTINUE 0
static int mmc_blk_cmd_error(struct request *req, const char *name, int error,
bool status_valid, u32 status)
{
switch (error) {
case -EILSEQ:
/* response crc error, retry the r/w cmd */
pr_err("%s: %s sending %s command, card status %#x\n",
req->rq_disk->disk_name, "response CRC error",
name, status);
return ERR_RETRY;
case -ETIMEDOUT:
pr_err("%s: %s sending %s command, card status %#x\n",
req->rq_disk->disk_name, "timed out", name, status);
/* If the status cmd initially failed, retry the r/w cmd */
if (!status_valid) {
pr_err("%s: status not valid, retrying timeout\n", req->rq_disk->disk_name);
return ERR_RETRY;
}
/*
* If it was a r/w cmd crc error, or illegal command
* (eg, issued in wrong state) then retry - we should
* have corrected the state problem above.
*/
if (status & (R1_COM_CRC_ERROR | R1_ILLEGAL_COMMAND)) {
pr_err("%s: command error, retrying timeout\n", req->rq_disk->disk_name);
return ERR_RETRY;
}
/* Otherwise abort the command */
pr_err("%s: not retrying timeout\n", req->rq_disk->disk_name);
return ERR_ABORT;
default:
/* We don't understand the error code the driver gave us */
pr_err("%s: unknown error %d sending read/write command, card status %#x\n",
req->rq_disk->disk_name, error, status);
return ERR_ABORT;
}
}
/*
* Initial r/w and stop cmd error recovery.
* We don't know whether the card received the r/w cmd or not, so try to
* restore things back to a sane state. Essentially, we do this as follows:
* - Obtain card status. If the first attempt to obtain card status fails,
* the status word will reflect the failed status cmd, not the failed
* r/w cmd. If we fail to obtain card status, it suggests we can no
* longer communicate with the card.
* - Check the card state. If the card received the cmd but there was a
* transient problem with the response, it might still be in a data transfer
* mode. Try to send it a stop command. If this fails, we can't recover.
* - If the r/w cmd failed due to a response CRC error, it was probably
* transient, so retry the cmd.
* - If the r/w cmd timed out, but we didn't get the r/w cmd status, retry.
* - If the r/w cmd timed out, and the r/w cmd failed due to CRC error or
* illegal cmd, retry.
* Otherwise we don't understand what happened, so abort.
*/
static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req,
struct mmc_blk_request *brq, int *ecc_err, int *gen_err)
{
bool prev_cmd_status_valid = true;
u32 status, stop_status = 0;
int err, retry;
if (mmc_card_removed(card))
return ERR_NOMEDIUM;
/*
* Try to get card status which indicates both the card state
* and why there was no response. If the first attempt fails,
* we can't be sure the returned status is for the r/w command.
*/
for (retry = 2; retry >= 0; retry--) {
err = get_card_status(card, &status, 0);
if (!err)
break;
prev_cmd_status_valid = false;
pr_err("%s: error %d sending status command, %sing\n",
req->rq_disk->disk_name, err, retry ? "retry" : "abort");
}
/* We couldn't get a response from the card. Give up. */
if (err) {
/* Check if the card is removed */
if (mmc_detect_card_removed(card->host))
return ERR_NOMEDIUM;
return ERR_ABORT;
}
/* Flag ECC errors */
if ((status & R1_CARD_ECC_FAILED) ||
(brq->stop.resp[0] & R1_CARD_ECC_FAILED) ||
(brq->cmd.resp[0] & R1_CARD_ECC_FAILED))
*ecc_err = 1;
/* Flag General errors */
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ)
if ((status & R1_ERROR) ||
(brq->stop.resp[0] & R1_ERROR)) {
pr_err("%s: %s: general error sending stop or status command, stop cmd response %#x, card status %#x\n",
req->rq_disk->disk_name, __func__,
brq->stop.resp[0], status);
*gen_err = 1;
}
/*
* Check the current card state. If it is in some data transfer
* mode, tell it to stop (and hopefully transition back to TRAN.)
*/
if (R1_CURRENT_STATE(status) == R1_STATE_DATA ||
R1_CURRENT_STATE(status) == R1_STATE_RCV) {
err = send_stop(card, &stop_status);
if (err)
pr_err("%s: error %d sending stop command\n",
req->rq_disk->disk_name, err);
/*
* If the stop cmd also timed out, the card is probably
* not present, so abort. Other errors are bad news too.
*/
if (err)
return ERR_ABORT;
if (stop_status & R1_CARD_ECC_FAILED)
*ecc_err = 1;
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ)
if (stop_status & R1_ERROR) {
pr_err("%s: %s: general error sending stop command, stop cmd response %#x\n",
req->rq_disk->disk_name, __func__,
stop_status);
*gen_err = 1;
}
}
/* Check for set block count errors */
if (brq->sbc.error)
return mmc_blk_cmd_error(req, "SET_BLOCK_COUNT", brq->sbc.error,
prev_cmd_status_valid, status);
/* Check for r/w command errors */
if (brq->cmd.error)
return mmc_blk_cmd_error(req, "r/w cmd", brq->cmd.error,
prev_cmd_status_valid, status);
/* Data errors */
if (!brq->stop.error)
return ERR_CONTINUE;
/* Now for stop errors. These aren't fatal to the transfer. */
pr_err("%s: error %d sending stop command, original cmd response %#x, card status %#x\n",
req->rq_disk->disk_name, brq->stop.error,
brq->cmd.resp[0], status);
/*
* Subsitute in our own stop status as this will give the error
* state which happened during the execution of the r/w command.
*/
if (stop_status) {
brq->stop.resp[0] = stop_status;
brq->stop.error = 0;
}
return ERR_CONTINUE;
}
static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
int type)
{
int err;
if (md->reset_done & type)
return -EEXIST;
md->reset_done |= type;
err = mmc_hw_reset(host);
if (err && err != -EOPNOTSUPP) {
/* We failed to reset so we need to abort the request */
pr_err("%s: %s: failed to reset %d\n", mmc_hostname(host),
__func__, err);
return -ENODEV;
}
/* Ensure we switch back to the correct partition */
if (host->card) {
struct mmc_blk_data *main_md = mmc_get_drvdata(host->card);
int part_err;
main_md->part_curr = main_md->part_type;
part_err = mmc_blk_part_switch(host->card, md);
if (part_err) {
/*
* We have failed to get back into the correct
* partition, so we need to abort the whole request.
*/
return -ENODEV;
}
}
return err;
}
static inline void mmc_blk_reset_success(struct mmc_blk_data *md, int type)
{
md->reset_done &= ~type;
}
static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
{
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
unsigned int from, nr, arg;
int err = 0, type = MMC_BLK_DISCARD;
if (!mmc_can_erase(card)) {
err = -EOPNOTSUPP;
goto out;
}
from = blk_rq_pos(req);
nr = blk_rq_sectors(req);
if (card->ext_csd.bkops_en)
card->bkops_info.sectors_changed += blk_rq_sectors(req);
if (mmc_can_discard(card))
arg = MMC_DISCARD_ARG;
else if (mmc_can_trim(card))
arg = MMC_TRIM_ARG;
else
arg = MMC_ERASE_ARG;
retry:
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
INAND_CMD38_ARG_EXT_CSD,
arg == MMC_TRIM_ARG ?
INAND_CMD38_ARG_TRIM :
INAND_CMD38_ARG_ERASE,
0);
if (err)
goto out;
}
err = mmc_erase(card, from, nr, arg);
out:
if (err == -EIO && !mmc_blk_reset(md, card->host, type))
goto retry;
if (!err)
mmc_blk_reset_success(md, type);
blk_end_request(req, err, blk_rq_bytes(req));
return err ? 0 : 1;
}
static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
struct request *req)
{
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
unsigned int from, nr, arg;
int err = 0, type = MMC_BLK_SECDISCARD;
if (!(mmc_can_secure_erase_trim(card))) {
err = -EOPNOTSUPP;
goto out;
}
from = blk_rq_pos(req);
nr = blk_rq_sectors(req);
if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
arg = MMC_SECURE_TRIM1_ARG;
else
arg = MMC_SECURE_ERASE_ARG;
retry:
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
INAND_CMD38_ARG_EXT_CSD,
arg == MMC_SECURE_TRIM1_ARG ?
INAND_CMD38_ARG_SECTRIM1 :
INAND_CMD38_ARG_SECERASE,
0);
if (err)
goto out_retry;
}
err = mmc_erase(card, from, nr, arg);
if (err == -EIO)
goto out_retry;
if (err)
goto out;
if (arg == MMC_SECURE_TRIM1_ARG) {
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
INAND_CMD38_ARG_EXT_CSD,
INAND_CMD38_ARG_SECTRIM2,
0);
if (err)
goto out_retry;
}
err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
if (err == -EIO)
goto out_retry;
if (err)
goto out;
}
out_retry:
if (err && !mmc_blk_reset(md, card->host, type))
goto retry;
if (!err)
mmc_blk_reset_success(md, type);
out:
blk_end_request(req, err, blk_rq_bytes(req));
return err ? 0 : 1;
}
static int mmc_blk_issue_sanitize_rq(struct mmc_queue *mq,
struct request *req)
{
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
int err = 0;
BUG_ON(!card);
BUG_ON(!card->host);
if (!(mmc_can_sanitize(card) &&
(card->host->caps2 & MMC_CAP2_SANITIZE))) {
pr_warning("%s: %s - SANITIZE is not supported\n",
mmc_hostname(card->host), __func__);
err = -EOPNOTSUPP;
goto out;
}
pr_debug("%s: %s - SANITIZE IN PROGRESS...\n",
mmc_hostname(card->host), __func__);
err = mmc_switch_ignore_timeout(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_SANITIZE_START, 1,
MMC_SANITIZE_REQ_TIMEOUT);
if (err)
pr_err("%s: %s - mmc_switch() with "
"EXT_CSD_SANITIZE_START failed. err=%d\n",
mmc_hostname(card->host), __func__, err);
pr_debug("%s: %s - SANITIZE COMPLETED\n", mmc_hostname(card->host),
__func__);
out:
blk_end_request(req, err, blk_rq_bytes(req));
return err ? 0 : 1;
}
static int mmc_blk_issue_flush(struct mmc_queue *mq, struct request *req)
{
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
int ret = 0;
ret = mmc_flush_cache(card);
if (ret)
ret = -EIO;
blk_end_request_all(req, ret);
return ret ? 0 : 1;
}
/*
* Reformat current write as a reliable write, supporting
* both legacy and the enhanced reliable write MMC cards.
* In each transfer we'll handle only as much as a single
* reliable write can handle, thus finish the request in
* partial completions.
*/
static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
struct mmc_card *card,
struct request *req)
{
if (!(card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN)) {
/* Legacy mode imposes restrictions on transfers. */
if (!IS_ALIGNED(brq->cmd.arg, card->ext_csd.rel_sectors))
brq->data.blocks = 1;
if (brq->data.blocks > card->ext_csd.rel_sectors)
brq->data.blocks = card->ext_csd.rel_sectors;
else if (brq->data.blocks < card->ext_csd.rel_sectors)
brq->data.blocks = 1;
}
}
#define CMD_ERRORS \
(R1_OUT_OF_RANGE | /* Command argument out of range */ \
R1_ADDRESS_ERROR | /* Misaligned address */ \
R1_BLOCK_LEN_ERROR | /* Transferred block length incorrect */\
R1_WP_VIOLATION | /* Tried to write to protected block */ \
R1_CC_ERROR | /* Card controller error */ \
R1_ERROR) /* General/unknown error */
static int mmc_blk_err_check(struct mmc_card *card,
struct mmc_async_req *areq)
{
struct mmc_queue_req *mq_mrq = container_of(areq, struct mmc_queue_req,
mmc_active);
struct mmc_blk_request *brq = &mq_mrq->brq;
struct request *req = mq_mrq->req;
int ecc_err = 0, gen_err = 0;
/*
* sbc.error indicates a problem with the set block count
* command. No data will have been transferred.
*
* cmd.error indicates a problem with the r/w command. No
* data will have been transferred.
*
* stop.error indicates a problem with the stop command. Data
* may have been transferred, or may still be transferring.
*/
if (brq->sbc.error || brq->cmd.error || brq->stop.error ||
brq->data.error) {
switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
case ERR_RETRY:
return MMC_BLK_RETRY;
case ERR_ABORT:
return MMC_BLK_ABORT;
case ERR_NOMEDIUM:
return MMC_BLK_NOMEDIUM;
case ERR_CONTINUE:
break;
}
}
/*
* Check for errors relating to the execution of the
* initial command - such as address errors. No data
* has been transferred.
*/
if (brq->cmd.resp[0] & CMD_ERRORS) {
pr_err("%s: r/w command failed, status = %#x\n",
req->rq_disk->disk_name, brq->cmd.resp[0]);
return MMC_BLK_ABORT;
}
/*
* Everything else is either success, or a data error of some
* kind. If it was a write, we may have transitioned to
* program mode, which we have to wait for it to complete.
*/
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
u32 status;
unsigned long timeout;
/* Check stop command response */
if (brq->stop.resp[0] & R1_ERROR) {
pr_err("%s: %s: general error sending stop command, stop cmd response %#x\n",
req->rq_disk->disk_name, __func__,
brq->stop.resp[0]);
gen_err = 1;
}
timeout = jiffies + msecs_to_jiffies(MMC_BLK_TIMEOUT_MS);
do {
int err = get_card_status(card, &status, 5);
if (err) {
pr_err("%s: error %d requesting status\n",
req->rq_disk->disk_name, err);
return MMC_BLK_CMD_ERR;
}
/* Timeout if the device never becomes ready for data
* and never leaves the program state.
*/
if (time_after(jiffies, timeout)) {
pr_err("%s: Card stuck in programming state!"\
" %s %s\n", mmc_hostname(card->host),
req->rq_disk->disk_name, __func__);
return MMC_BLK_CMD_ERR;
}
if (status & R1_ERROR) {
pr_err("%s: %s: general error sending status command, card status %#x\n",
req->rq_disk->disk_name, __func__,
status);
gen_err = 1;
}
/*
* Some cards mishandle the status bits,
* so make sure to check both the busy
* indication and the card state.
*/
} while (!(status & R1_READY_FOR_DATA) ||
(R1_CURRENT_STATE(status) == R1_STATE_PRG));
}
/* if general error occurs, retry the write operation. */
if (gen_err) {
pr_warning("%s: retrying write for general error\n",
req->rq_disk->disk_name);
return MMC_BLK_RETRY;
}
if (brq->data.error) {
pr_err("%s: error %d transferring data, sector %u, nr %u, cmd response %#x, card status %#x\n",
req->rq_disk->disk_name, brq->data.error,
(unsigned)blk_rq_pos(req),
(unsigned)blk_rq_sectors(req),
brq->cmd.resp[0], brq->stop.resp[0]);
if (rq_data_dir(req) == READ) {
if (ecc_err)
return MMC_BLK_ECC_ERR;
return MMC_BLK_DATA_ERR;
} else {
return MMC_BLK_CMD_ERR;
}
}
if (!brq->data.bytes_xfered)
return MMC_BLK_RETRY;
if (mq_mrq->packed_cmd != MMC_PACKED_NONE) {
if (unlikely(brq->data.blocks << 9 != brq->data.bytes_xfered))
return MMC_BLK_PARTIAL;
else
return MMC_BLK_SUCCESS;
}
if (blk_rq_bytes(req) != brq->data.bytes_xfered)
return MMC_BLK_PARTIAL;
return MMC_BLK_SUCCESS;
}
/*
* mmc_blk_reinsert_req() - re-insert request back to the scheduler
* @areq: request to re-insert.
*
* Request may be packed or single. When fails to reinsert request, it will be
* requeued to the the dispatch queue.
*/
static void mmc_blk_reinsert_req(struct mmc_async_req *areq)
{
struct request *prq;
int ret = 0;
struct mmc_queue_req *mq_rq;
struct request_queue *q;
mq_rq = container_of(areq, struct mmc_queue_req, mmc_active);
q = mq_rq->req->q;
if (mq_rq->packed_cmd != MMC_PACKED_NONE) {
while (!list_empty(&mq_rq->packed_list)) {
/* return requests in reverse order */
prq = list_entry_rq(mq_rq->packed_list.prev);
list_del_init(&prq->queuelist);
spin_lock_irq(q->queue_lock);
ret = blk_reinsert_request(q, prq);
if (ret) {
blk_requeue_request(q, prq);
spin_unlock_irq(q->queue_lock);
goto reinsert_error;
}
spin_unlock_irq(q->queue_lock);
}
} else {
spin_lock_irq(q->queue_lock);
ret = blk_reinsert_request(q, mq_rq->req);
if (ret)
blk_requeue_request(q, mq_rq->req);
spin_unlock_irq(q->queue_lock);
}
return;
reinsert_error:
pr_err("%s: blk_reinsert_request() failed (%d)",
mq_rq->req->rq_disk->disk_name, ret);
/*
* -EIO will be reported for this request and rest of packed_list.
* Urgent request will be proceeded anyway, while upper layer
* responsibility to re-send failed requests
*/
while (!list_empty(&mq_rq->packed_list)) {
prq = list_entry_rq(mq_rq->packed_list.next);
list_del_init(&prq->queuelist);
spin_lock_irq(q->queue_lock);
blk_requeue_request(q, prq);
spin_unlock_irq(q->queue_lock);
}
}
/*
* mmc_blk_update_interrupted_req() - update of the stopped request
* @card: the MMC card associated with the request.
* @areq: interrupted async request.
*
* Get stopped request state from card and update successfully done part of
* the request by setting packed_fail_idx. The packed_fail_idx is index of
* first uncompleted request in packed request list, for non-packed request
* packed_fail_idx remains unchanged.
*
* Returns: MMC_BLK_SUCCESS for success, MMC_BLK_ABORT otherwise
*/
static int mmc_blk_update_interrupted_req(struct mmc_card *card,
struct mmc_async_req *areq)
{
int ret = MMC_BLK_SUCCESS;
u8 *ext_csd;
int correctly_done;
struct mmc_queue_req *mq_rq = container_of(areq, struct mmc_queue_req,
mmc_active);
struct request *prq;
u8 req_index = 0;
if (mq_rq->packed_cmd == MMC_PACKED_NONE)
return MMC_BLK_SUCCESS;
ext_csd = kmalloc(512, GFP_KERNEL);
if (!ext_csd)
return MMC_BLK_ABORT;
/* get correctly programmed sectors number from card */
ret = mmc_send_ext_csd(card, ext_csd);
if (ret) {
pr_err("%s: error %d reading ext_csd\n",
mmc_hostname(card->host), ret);
ret = MMC_BLK_ABORT;
goto exit;
}
correctly_done = card->ext_csd.data_sector_size *
(ext_csd[EXT_CSD_CORRECTLY_PRG_SECTORS_NUM + 0] << 0 |
ext_csd[EXT_CSD_CORRECTLY_PRG_SECTORS_NUM + 1] << 8 |
ext_csd[EXT_CSD_CORRECTLY_PRG_SECTORS_NUM + 2] << 16 |
ext_csd[EXT_CSD_CORRECTLY_PRG_SECTORS_NUM + 3] << 24);
/*
* skip packed command header (1 sector) included by the counter but not
* actually written to the NAND
*/
if (correctly_done >= card->ext_csd.data_sector_size)
correctly_done -= card->ext_csd.data_sector_size;
list_for_each_entry(prq, &mq_rq->packed_list, queuelist) {
if ((correctly_done - (int)blk_rq_bytes(prq)) < 0) {
/* prq is not successfull */
mq_rq->packed_fail_idx = req_index;
break;
}
correctly_done -= blk_rq_bytes(prq);
req_index++;
}
exit:
kfree(ext_csd);
return ret;
}
static int mmc_blk_packed_err_check(struct mmc_card *card,
struct mmc_async_req *areq)
{
struct mmc_queue_req *mq_rq = container_of(areq, struct mmc_queue_req,
mmc_active);
struct request *req = mq_rq->req;
int err, check, status;
u8 ext_csd[512];
mq_rq->packed_retries--;
check = mmc_blk_err_check(card, areq);
err = get_card_status(card, &status, 0);
if (err) {
pr_err("%s: error %d sending status command\n",
req->rq_disk->disk_name, err);
return MMC_BLK_ABORT;
}
if (status & R1_EXCEPTION_EVENT) {
err = mmc_send_ext_csd(card, ext_csd);
if (err) {
pr_err("%s: error %d sending ext_csd\n",
req->rq_disk->disk_name, err);
return MMC_BLK_ABORT;
}
if ((ext_csd[EXT_CSD_EXP_EVENTS_STATUS] &
EXT_CSD_PACKED_FAILURE) &&
(ext_csd[EXT_CSD_PACKED_CMD_STATUS] &
EXT_CSD_PACKED_GENERIC_ERROR)) {
if (ext_csd[EXT_CSD_PACKED_CMD_STATUS] &
EXT_CSD_PACKED_INDEXED_ERROR) {
mq_rq->packed_fail_idx =
ext_csd[EXT_CSD_PACKED_FAILURE_INDEX] - 1;
return MMC_BLK_PARTIAL;
}
}
}
return check;
}
static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
struct mmc_card *card,
int disable_multi,
struct mmc_queue *mq)
{
u32 readcmd, writecmd;
struct mmc_blk_request *brq = &mqrq->brq;
struct request *req = mqrq->req;
struct mmc_blk_data *md = mq->data;
bool do_data_tag;
unsigned long flags;
/*
* Reliable writes are used to implement Forced Unit Access and
* REQ_META accesses, and are supported only on MMCs.
*
* XXX: this really needs a good explanation of why REQ_META
* is treated special.
*/
bool do_rel_wr = ((req->cmd_flags & REQ_FUA) ||
(req->cmd_flags & REQ_META)) &&
(rq_data_dir(req) == WRITE) &&
(md->flags & MMC_BLK_REL_WR);
spin_lock_irqsave(&card->host->mrq_lock, flags);
memset(brq, 0, sizeof(struct mmc_blk_request));
brq->mrq.cmd = &brq->cmd;
brq->mrq.data = &brq->data;
brq->cmd.arg = blk_rq_pos(req);
if (!mmc_card_blockaddr(card))
brq->cmd.arg <<= 9;
brq->cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
brq->data.blksz = 512;
brq->stop.opcode = MMC_STOP_TRANSMISSION;
brq->stop.arg = 0;
brq->stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
brq->data.blocks = blk_rq_sectors(req);
brq->data.fault_injected = false;
/*
* The block layer doesn't support all sector count
* restrictions, so we need to be prepared for too big
* requests.
*/
if (brq->data.blocks > card->host->max_blk_count)
brq->data.blocks = card->host->max_blk_count;
if (brq->data.blocks > 1) {
/*
* After a read error, we redo the request one sector
* at a time in order to accurately determine which
* sectors can be read successfully.
*/
if (disable_multi)
brq->data.blocks = 1;
/* Some controllers can't do multiblock reads due to hw bugs */
if (card->host->caps2 & MMC_CAP2_NO_MULTI_READ &&
rq_data_dir(req) == READ)
brq->data.blocks = 1;
}
if (brq->data.blocks > 1 || do_rel_wr) {
/* SPI multiblock writes terminate using a special
* token, not a STOP_TRANSMISSION request.
*/
if (!mmc_host_is_spi(card->host) ||
rq_data_dir(req) == READ)
brq->mrq.stop = &brq->stop;
readcmd = MMC_READ_MULTIPLE_BLOCK;
writecmd = MMC_WRITE_MULTIPLE_BLOCK;
} else {
brq->mrq.stop = NULL;
readcmd = MMC_READ_SINGLE_BLOCK;
writecmd = MMC_WRITE_BLOCK;
}
if (rq_data_dir(req) == READ) {
brq->cmd.opcode = readcmd;
brq->data.flags |= MMC_DATA_READ;
} else {
brq->cmd.opcode = writecmd;
brq->data.flags |= MMC_DATA_WRITE;
}
if (do_rel_wr)
mmc_apply_rel_rw(brq, card, req);
/*
* Data tag is used only during writing meta data to speed
* up write and any subsequent read of this meta data
*/
do_data_tag = (card->ext_csd.data_tag_unit_size) &&
(req->cmd_flags & REQ_META) &&
(rq_data_dir(req) == WRITE) &&
((brq->data.blocks * brq->data.blksz) >=
card->ext_csd.data_tag_unit_size);
/*
* Pre-defined multi-block transfers are preferable to
* open ended-ones (and necessary for reliable writes).
* However, it is not sufficient to just send CMD23,
* and avoid the final CMD12, as on an error condition
* CMD12 (stop) needs to be sent anyway. This, coupled
* with Auto-CMD23 enhancements provided by some
* hosts, means that the complexity of dealing
* with this is best left to the host. If CMD23 is
* supported by card and host, we'll fill sbc in and let
* the host deal with handling it correctly. This means
* that for hosts that don't expose MMC_CAP_CMD23, no
* change of behavior will be observed.
*
* N.B: Some MMC cards experience perf degradation.
* We'll avoid using CMD23-bounded multiblock writes for
* these, while retaining features like reliable writes.
*/
if ((md->flags & MMC_BLK_CMD23) && mmc_op_multi(brq->cmd.opcode) &&
(do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23) ||
do_data_tag)) {
brq->sbc.opcode = MMC_SET_BLOCK_COUNT;
brq->sbc.arg = brq->data.blocks |
(do_rel_wr ? (1 << 31) : 0) |
(do_data_tag ? (1 << 29) : 0);
brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC;
brq->mrq.sbc = &brq->sbc;
}
mmc_set_data_timeout(&brq->data, card);
brq->data.sg = mqrq->sg;
brq->data.sg_len = mmc_queue_map_sg(mq, mqrq);
/*
* Adjust the sg list so it is the same size as the
* request.
*/
if (brq->data.blocks != blk_rq_sectors(req)) {
int i, data_size = brq->data.blocks << 9;
struct scatterlist *sg;
for_each_sg(brq->data.sg, sg, brq->data.sg_len, i) {
data_size -= sg->length;
if (data_size <= 0) {
sg->length += data_size;
i++;
break;
}
}
brq->data.sg_len = i;
}
mqrq->mmc_active.mrq = &brq->mrq;
mqrq->mmc_active.cmd_flags = req->cmd_flags;
spin_unlock_irqrestore(&card->host->mrq_lock, flags);
if (mq->err_check_fn)
mqrq->mmc_active.err_check = mq->err_check_fn;
else
mqrq->mmc_active.err_check = mmc_blk_err_check;
mqrq->mmc_active.reinsert_req = mmc_blk_reinsert_req;
mqrq->mmc_active.update_interrupted_req =
mmc_blk_update_interrupted_req;
mmc_queue_bounce_pre(mqrq);
}
/**
* mmc_blk_disable_wr_packing() - disables packing mode
* @mq: MMC queue.
*
*/
void mmc_blk_disable_wr_packing(struct mmc_queue *mq)
{
if (mq) {
mq->wr_packing_enabled = false;
mq->num_of_potential_packed_wr_reqs = 0;
}
}
EXPORT_SYMBOL(mmc_blk_disable_wr_packing);
static int get_packed_trigger(int potential, struct mmc_card *card,
struct request *req, int curr_trigger)
{
static int num_mean_elements = 1;
static unsigned long mean_potential = PCKD_TRGR_INIT_MEAN_POTEN;
unsigned int trigger = curr_trigger;
unsigned int pckd_trgr_upper_bound = card->ext_csd.max_packed_writes;
/* scale down the upper bound to 75% */
pckd_trgr_upper_bound = (pckd_trgr_upper_bound * 3) / 4;
/*
* since the most common calls for this function are with small
* potential write values and since we don't want these calls to affect
* the packed trigger, set a lower bound and ignore calls with
* potential lower than that bound
*/
if (potential <= PCKD_TRGR_POTEN_LOWER_BOUND)
return trigger;
/*
* this is to prevent integer overflow in the following calculation:
* once every PACKED_TRIGGER_MAX_ELEMENTS reset the algorithm
*/
if (num_mean_elements > PACKED_TRIGGER_MAX_ELEMENTS) {
num_mean_elements = 1;
mean_potential = PCKD_TRGR_INIT_MEAN_POTEN;
}
/*
* get next mean value based on previous mean value and current
* potential packed writes. Calculation is as follows:
* mean_pot[i+1] =
* ((mean_pot[i] * num_mean_elem) + potential)/(num_mean_elem + 1)
*/
mean_potential *= num_mean_elements;
/*
* add num_mean_elements so that the division of two integers doesn't
* lower mean_potential too much
*/
if (potential > mean_potential)
mean_potential += num_mean_elements;
mean_potential += potential;
/* this is for gaining more precision when dividing two integers */
mean_potential *= PCKD_TRGR_PRECISION_MULTIPLIER;
/* this completes the mean calculation */
mean_potential /= ++num_mean_elements;
mean_potential /= PCKD_TRGR_PRECISION_MULTIPLIER;
/*
* if current potential packed writes is greater than the mean potential
* then the heuristic is that the following workload will contain many
* write requests, therefore we lower the packed trigger. In the
* opposite case we want to increase the trigger in order to get less
* packing events.
*/
if (potential >= mean_potential)
trigger = (trigger <= PCKD_TRGR_LOWER_BOUND) ?
PCKD_TRGR_LOWER_BOUND : trigger - 1;
else
trigger = (trigger >= pckd_trgr_upper_bound) ?
pckd_trgr_upper_bound : trigger + 1;
/*
* an urgent read request indicates a packed list being interrupted
* by this read, therefore we aim for less packing, hence the trigger
* gets increased
*/
if (req && (req->cmd_flags & REQ_URGENT) && (rq_data_dir(req) == READ))
trigger += PCKD_TRGR_URGENT_PENALTY;
return trigger;
}
static void mmc_blk_write_packing_control(struct mmc_queue *mq,
struct request *req)
{
struct mmc_host *host = mq->card->host;
int data_dir;
if (!(host->caps2 & MMC_CAP2_PACKED_WR))
return;
/* Support for the write packing on eMMC 4.5 or later */
if (mq->card->ext_csd.rev <= 5)
return;
/*
* In case the packing control is not supported by the host, it should
* not have an effect on the write packing. Therefore we have to enable
* the write packing
*/
if (!(host->caps2 & MMC_CAP2_PACKED_WR_CONTROL)) {
mq->wr_packing_enabled = true;
return;
}
if (!req || (req && (req->cmd_flags & REQ_FLUSH))) {
if (mq->num_of_potential_packed_wr_reqs >
mq->num_wr_reqs_to_start_packing)
mq->wr_packing_enabled = true;
mq->num_wr_reqs_to_start_packing =
get_packed_trigger(mq->num_of_potential_packed_wr_reqs,
mq->card, req,
mq->num_wr_reqs_to_start_packing);
mq->num_of_potential_packed_wr_reqs = 0;
return;
}
data_dir = rq_data_dir(req);
if (data_dir == READ) {
mmc_blk_disable_wr_packing(mq);
mq->num_wr_reqs_to_start_packing =
get_packed_trigger(mq->num_of_potential_packed_wr_reqs,
mq->card, req,
mq->num_wr_reqs_to_start_packing);
mq->num_of_potential_packed_wr_reqs = 0;
mq->wr_packing_enabled = false;
return;
} else if (data_dir == WRITE) {
mq->num_of_potential_packed_wr_reqs++;
}
if (mq->num_of_potential_packed_wr_reqs >
mq->num_wr_reqs_to_start_packing)
mq->wr_packing_enabled = true;
}
struct mmc_wr_pack_stats *mmc_blk_get_packed_statistics(struct mmc_card *card)
{
if (!card)
return NULL;
return &card->wr_pack_stats;
}
EXPORT_SYMBOL(mmc_blk_get_packed_statistics);
void mmc_blk_init_packed_statistics(struct mmc_card *card)
{
int max_num_of_packed_reqs = 0;
if (!card || !card->wr_pack_stats.packing_events)
return;
max_num_of_packed_reqs = card->ext_csd.max_packed_writes;
spin_lock(&card->wr_pack_stats.lock);
memset(card->wr_pack_stats.packing_events, 0,
(max_num_of_packed_reqs + 1) *
sizeof(*card->wr_pack_stats.packing_events));
memset(&card->wr_pack_stats.pack_stop_reason, 0,
sizeof(card->wr_pack_stats.pack_stop_reason));
card->wr_pack_stats.enabled = true;
spin_unlock(&card->wr_pack_stats.lock);
}
EXPORT_SYMBOL(mmc_blk_init_packed_statistics);
static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req)
{
struct request_queue *q = mq->queue;
struct mmc_card *card = mq->card;
struct request *cur = req, *next = NULL;
struct mmc_blk_data *md = mq->data;
bool en_rel_wr = card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN;
unsigned int req_sectors = 0, phys_segments = 0;
unsigned int max_blk_count, max_phys_segs;
u8 put_back = 0;
u8 max_packed_rw = 0;
u8 reqs = 0;
struct mmc_wr_pack_stats *stats = &card->wr_pack_stats;
mmc_blk_clear_packed(mq->mqrq_cur);
if (!(md->flags & MMC_BLK_CMD23) ||
!card->ext_csd.packed_event_en)
goto no_packed;
if (!mq->wr_packing_enabled)
goto no_packed;
if ((rq_data_dir(cur) == WRITE) &&
(card->host->caps2 & MMC_CAP2_PACKED_WR))
max_packed_rw = card->ext_csd.max_packed_writes;
if (max_packed_rw == 0)
goto no_packed;
if (mmc_req_rel_wr(cur) &&
(md->flags & MMC_BLK_REL_WR) &&
!en_rel_wr)
goto no_packed;
if (mmc_large_sec(card) &&
!IS_ALIGNED(blk_rq_sectors(cur), 8))
goto no_packed;
if (cur->cmd_flags & REQ_FUA)
goto no_packed;
max_blk_count = min(card->host->max_blk_count,
card->host->max_req_size >> 9);
if (unlikely(max_blk_count > 0xffff))
max_blk_count = 0xffff;
max_phys_segs = queue_max_segments(q);
req_sectors += blk_rq_sectors(cur);
phys_segments += cur->nr_phys_segments;
if (rq_data_dir(cur) == WRITE) {
req_sectors++;
phys_segments++;
}
spin_lock(&stats->lock);
while (reqs < max_packed_rw - 1) {
spin_lock_irq(q->queue_lock);
next = blk_fetch_request(q);
spin_unlock_irq(q->queue_lock);
if (!next) {
MMC_BLK_UPDATE_STOP_REASON(stats, EMPTY_QUEUE);
break;
}
if (mmc_large_sec(card) &&
!IS_ALIGNED(blk_rq_sectors(next), 8)) {
MMC_BLK_UPDATE_STOP_REASON(stats, LARGE_SEC_ALIGN);
put_back = 1;
break;
}
if (next->cmd_flags & REQ_DISCARD ||
next->cmd_flags & REQ_FLUSH) {
MMC_BLK_UPDATE_STOP_REASON(stats, FLUSH_OR_DISCARD);
put_back = 1;
break;
}
if (next->cmd_flags & REQ_FUA) {
MMC_BLK_UPDATE_STOP_REASON(stats, FUA);
put_back = 1;
break;
}
if (rq_data_dir(cur) != rq_data_dir(next)) {
MMC_BLK_UPDATE_STOP_REASON(stats, WRONG_DATA_DIR);
put_back = 1;
break;
}
if (mmc_req_rel_wr(next) &&
(md->flags & MMC_BLK_REL_WR) &&
!en_rel_wr) {
MMC_BLK_UPDATE_STOP_REASON(stats, REL_WRITE);
put_back = 1;
break;
}
req_sectors += blk_rq_sectors(next);
if (req_sectors > max_blk_count) {
if (stats->enabled)
stats->pack_stop_reason[EXCEEDS_SECTORS]++;
put_back = 1;
break;
}
phys_segments += next->nr_phys_segments;
if (phys_segments > max_phys_segs) {
MMC_BLK_UPDATE_STOP_REASON(stats, EXCEEDS_SEGMENTS);
put_back = 1;
break;
}
if (mq->no_pack_for_random) {
if ((blk_rq_pos(cur) + blk_rq_sectors(cur)) !=
blk_rq_pos(next)) {
MMC_BLK_UPDATE_STOP_REASON(stats, RANDOM);
put_back = 1;
break;
}
}
if (rq_data_dir(next) == WRITE) {
mq->num_of_potential_packed_wr_reqs++;
if (card->ext_csd.bkops_en)
card->bkops_info.sectors_changed +=
blk_rq_sectors(next);
}
list_add_tail(&next->queuelist, &mq->mqrq_cur->packed_list);
cur = next;
reqs++;
}
if (put_back) {
spin_lock_irq(q->queue_lock);
blk_requeue_request(q, next);
spin_unlock_irq(q->queue_lock);
}
if (stats->enabled) {
if (reqs + 1 <= card->ext_csd.max_packed_writes)
stats->packing_events[reqs + 1]++;
if (reqs + 1 == max_packed_rw)
MMC_BLK_UPDATE_STOP_REASON(stats, THRESHOLD);
}
spin_unlock(&stats->lock);
if (reqs > 0) {
list_add(&req->queuelist, &mq->mqrq_cur->packed_list);
mq->mqrq_cur->packed_num = ++reqs;
mq->mqrq_cur->packed_retries = reqs;
return reqs;
}
no_packed:
mmc_blk_clear_packed(mq->mqrq_cur);
return 0;
}
static void mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq,
struct mmc_card *card,
struct mmc_queue *mq)
{
struct mmc_blk_request *brq = &mqrq->brq;
struct request *req = mqrq->req;
struct request *prq;
struct mmc_blk_data *md = mq->data;
bool do_rel_wr, do_data_tag;
u32 *packed_cmd_hdr = mqrq->packed_cmd_hdr;
u8 i = 1;
mqrq->packed_cmd = MMC_PACKED_WRITE;
mqrq->packed_blocks = 0;
mqrq->packed_fail_idx = MMC_PACKED_N_IDX;
memset(packed_cmd_hdr, 0, sizeof(mqrq->packed_cmd_hdr));
packed_cmd_hdr[0] = (mqrq->packed_num << 16) |
(PACKED_CMD_WR << 8) | PACKED_CMD_VER;
/*
* Argument for each entry of packed group
*/
list_for_each_entry(prq, &mqrq->packed_list, queuelist) {
do_rel_wr = mmc_req_rel_wr(prq) && (md->flags & MMC_BLK_REL_WR);
do_data_tag = (card->ext_csd.data_tag_unit_size) &&
(prq->cmd_flags & REQ_META) &&
(rq_data_dir(prq) == WRITE) &&
((brq->data.blocks * brq->data.blksz) >=
card->ext_csd.data_tag_unit_size);
/* Argument of CMD23 */
packed_cmd_hdr[(i * 2)] =
(do_rel_wr ? MMC_CMD23_ARG_REL_WR : 0) |
(do_data_tag ? MMC_CMD23_ARG_TAG_REQ : 0) |
blk_rq_sectors(prq);
/* Argument of CMD18 or CMD25 */
packed_cmd_hdr[((i * 2)) + 1] =
mmc_card_blockaddr(card) ?
blk_rq_pos(prq) : blk_rq_pos(prq) << 9;
mqrq->packed_blocks += blk_rq_sectors(prq);
i++;
}
memset(brq, 0, sizeof(struct mmc_blk_request));
brq->mrq.cmd = &brq->cmd;
brq->mrq.data = &brq->data;
brq->mrq.sbc = &brq->sbc;
brq->mrq.stop = &brq->stop;
brq->sbc.opcode = MMC_SET_BLOCK_COUNT;
brq->sbc.arg = MMC_CMD23_ARG_PACKED | (mqrq->packed_blocks + 1);
brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC;
brq->cmd.opcode = MMC_WRITE_MULTIPLE_BLOCK;
brq->cmd.arg = blk_rq_pos(req);
if (!mmc_card_blockaddr(card))
brq->cmd.arg <<= 9;
brq->cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
brq->data.blksz = 512;
brq->data.blocks = mqrq->packed_blocks + 1;
brq->data.flags |= MMC_DATA_WRITE;
brq->data.fault_injected = false;
brq->stop.opcode = MMC_STOP_TRANSMISSION;
brq->stop.arg = 0;
brq->stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
mmc_set_data_timeout(&brq->data, card);
brq->data.sg = mqrq->sg;
brq->data.sg_len = mmc_queue_map_sg(mq, mqrq);
mqrq->mmc_active.mrq = &brq->mrq;
mqrq->mmc_active.cmd_flags = req->cmd_flags;
/*
* This is intended for packed commands tests usage - in case these
* functions are not in use the respective pointers are NULL
*/
if (mq->err_check_fn)
mqrq->mmc_active.err_check = mq->err_check_fn;
else
mqrq->mmc_active.err_check = mmc_blk_packed_err_check;
if (mq->packed_test_fn)
mq->packed_test_fn(mq->queue, mqrq);
mqrq->mmc_active.reinsert_req = mmc_blk_reinsert_req;
mqrq->mmc_active.update_interrupted_req =
mmc_blk_update_interrupted_req;
mmc_queue_bounce_pre(mqrq);
}
static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card,
struct mmc_blk_request *brq, struct request *req,
int ret)
{
struct mmc_queue_req *mq_rq;
mq_rq = container_of(brq, struct mmc_queue_req, brq);
/*
* If this is an SD card and we're writing, we can first
* mark the known good sectors as ok.
*
* If the card is not SD, we can still ok written sectors
* as reported by the controller (which might be less than
* the real number of written sectors, but never more).
*/
if (mmc_card_sd(card)) {
u32 blocks;
if (!brq->data.fault_injected) {
blocks = mmc_sd_num_wr_blocks(card);
if (blocks != (u32)-1)
ret = blk_end_request(req, 0, blocks << 9);
} else
ret = blk_end_request(req, 0, brq->data.bytes_xfered);
} else {
if (mq_rq->packed_cmd == MMC_PACKED_NONE)
ret = blk_end_request(req, 0, brq->data.bytes_xfered);
}
return ret;
}
static int mmc_blk_end_packed_req(struct mmc_queue_req *mq_rq)
{
struct request *prq;
int idx = mq_rq->packed_fail_idx, i = 0;
int ret = 0;
while (!list_empty(&mq_rq->packed_list)) {
prq = list_entry_rq(mq_rq->packed_list.next);
if (idx == i) {
/* retry from error index */
mq_rq->packed_num -= idx;
mq_rq->req = prq;
ret = 1;
if (mq_rq->packed_num == MMC_PACKED_N_SINGLE) {
list_del_init(&prq->queuelist);
mmc_blk_clear_packed(mq_rq);
}
return ret;
}
list_del_init(&prq->queuelist);
blk_end_request(prq, 0, blk_rq_bytes(prq));
i++;
}
mmc_blk_clear_packed(mq_rq);
return ret;
}
static void mmc_blk_abort_packed_req(struct mmc_queue_req *mq_rq,
unsigned int cmd_flags)
{
struct request *prq;
while (!list_empty(&mq_rq->packed_list)) {
prq = list_entry_rq(mq_rq->packed_list.next);
list_del_init(&prq->queuelist);
prq->cmd_flags |= cmd_flags;
blk_end_request(prq, -EIO, blk_rq_bytes(prq));
}
mmc_blk_clear_packed(mq_rq);
}
static void mmc_blk_revert_packed_req(struct mmc_queue *mq,
struct mmc_queue_req *mq_rq)
{
struct request *prq;
struct request_queue *q = mq->queue;
while (!list_empty(&mq_rq->packed_list)) {
prq = list_entry_rq(mq_rq->packed_list.prev);
if (prq->queuelist.prev != &mq_rq->packed_list) {
list_del_init(&prq->queuelist);
spin_lock_irq(q->queue_lock);
blk_requeue_request(mq->queue, prq);
spin_unlock_irq(q->queue_lock);
} else {
list_del_init(&prq->queuelist);
}
}
mmc_blk_clear_packed(mq_rq);
}
static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
{
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
struct mmc_blk_request *brq = &mq->mqrq_cur->brq;
int ret = 1, disable_multi = 0, retry = 0, type;
enum mmc_blk_status status;
struct mmc_queue_req *mq_rq;
struct request *req;
struct mmc_async_req *areq;
const u8 packed_num = 2;
u8 reqs = 0;
if (!rqc && !mq->mqrq_prev->req)
return 0;
if (rqc) {
if ((card->ext_csd.bkops_en) && (rq_data_dir(rqc) == WRITE))
card->bkops_info.sectors_changed += blk_rq_sectors(rqc);
reqs = mmc_blk_prep_packed_list(mq, rqc);
}
do {
if (rqc) {
if (reqs >= packed_num)
mmc_blk_packed_hdr_wrq_prep(mq->mqrq_cur,
card, mq);
else
mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
areq = &mq->mqrq_cur->mmc_active;
} else
areq = NULL;
areq = mmc_start_req(card->host, areq, (int *) &status);
if (!areq) {
if (status == MMC_BLK_NEW_REQUEST)
set_bit(MMC_QUEUE_NEW_REQUEST, &mq->flags);
return 0;
}
mq_rq = container_of(areq, struct mmc_queue_req, mmc_active);
brq = &mq_rq->brq;
req = mq_rq->req;
type = rq_data_dir(req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE;
mmc_queue_bounce_post(mq_rq);
switch (status) {
case MMC_BLK_URGENT:
if (mq_rq->packed_cmd != MMC_PACKED_NONE) {
/* complete successfully transmitted part */
if (mmc_blk_end_packed_req(mq_rq))
/* process for not transmitted part */
mmc_blk_reinsert_req(areq);
} else {
mmc_blk_reinsert_req(areq);
}
set_bit(MMC_QUEUE_URGENT_REQUEST, &mq->flags);
ret = 0;
break;
case MMC_BLK_URGENT_DONE:
case MMC_BLK_SUCCESS:
case MMC_BLK_PARTIAL:
/*
* A block was successfully transferred.
*/
mmc_blk_reset_success(md, type);
if (mq_rq->packed_cmd != MMC_PACKED_NONE) {
ret = mmc_blk_end_packed_req(mq_rq);
break;
} else {
ret = blk_end_request(req, 0,
brq->data.bytes_xfered);
}
/*
* If the blk_end_request function returns non-zero even
* though all data has been transferred and no errors
* were returned by the host controller, it's a bug.
*/
if (status == MMC_BLK_SUCCESS && ret) {
pr_err("%s BUG rq_tot %d d_xfer %d\n",
__func__, blk_rq_bytes(req),
brq->data.bytes_xfered);
rqc = NULL;
goto cmd_abort;
}
break;
case MMC_BLK_CMD_ERR:
ret = mmc_blk_cmd_err(md, card, brq, req, ret);
if (!mmc_blk_reset(md, card->host, type)) {
if (!ret) {
/*
* We have successfully completed block
* request and notified to upper layers.
* As the reset is successful, assume
* h/w is in clean state and proceed
* with new request.
*/
BUG_ON(card->host->areq);
goto start_new_req;
}
break;
}
goto cmd_abort;
case MMC_BLK_RETRY:
if (retry++ < MMC_BLK_MAX_RETRIES)
break;
/* Fall through */
case MMC_BLK_ABORT:
if (!mmc_blk_reset(md, card->host, type) &&
(retry++ < (MMC_BLK_MAX_RETRIES + 1)))
break;
goto cmd_abort;
case MMC_BLK_DATA_ERR: {
int err;
err = mmc_blk_reset(md, card->host, type);
if (!err)
break;
if (err == -ENODEV ||
mq_rq->packed_cmd != MMC_PACKED_NONE)
goto cmd_abort;
/* Fall through */
}
case MMC_BLK_ECC_ERR:
if (brq->data.blocks > 1) {
/* Redo read one sector at a time */
pr_warning("%s: retrying using single block read\n",
req->rq_disk->disk_name);
disable_multi = 1;
break;
}
/*
* case : SDcard Sector 0 read data error even single read
* skip reading other blocks.
*/
if (mmc_card_sd(card) &&
(unsigned)blk_rq_pos(req) == 0 &&
brq->data.error)
goto cmd_abort;
/*
* After an error, we redo I/O one sector at a
* time, so we only reach here after trying to
* read a single sector.
*/
ret = blk_end_request(req, -EIO,
brq->data.blksz);
if (!ret)
goto start_new_req;
break;
case MMC_BLK_NOMEDIUM:
goto cmd_abort;
default:
pr_err("%s:%s: Unhandled return value (%d)",
req->rq_disk->disk_name,
__func__, status);
goto cmd_abort;
}
if (ret) {
if (mq_rq->packed_cmd == MMC_PACKED_NONE) {
/*
* In case of a incomplete request
* prepare it again and resend.
*/
mmc_blk_rw_rq_prep(mq_rq, card,
disable_multi, mq);
mmc_start_req(card->host,
&mq_rq->mmc_active, NULL);
} else {
if (!mq_rq->packed_retries)
goto cmd_abort;
mmc_blk_packed_hdr_wrq_prep(mq_rq, card, mq);
mmc_start_req(card->host,
&mq_rq->mmc_active, NULL);
}
}
} while (ret);
return 1;
cmd_abort:
if (mq_rq->packed_cmd == MMC_PACKED_NONE) {
if (mmc_card_removed(card))
req->cmd_flags |= REQ_QUIET;
while (ret)
ret = blk_end_request(req, -EIO,
blk_rq_cur_bytes(req));
} else {
mmc_blk_abort_packed_req(mq_rq, 0);
}
start_new_req:
if (rqc) {
if (mmc_card_removed(card)) {
if (mq_rq->packed_cmd == MMC_PACKED_NONE) {
rqc->cmd_flags |= REQ_QUIET;
blk_end_request_all(rqc, -EIO);
} else {
mmc_blk_abort_packed_req(mq_rq, REQ_QUIET);
}
} else {
/* If current request is packed, it needs to put back */
if (mq_rq->packed_cmd != MMC_PACKED_NONE)
mmc_blk_revert_packed_req(mq, mq->mqrq_cur);
mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
mmc_start_req(card->host,
&mq->mqrq_cur->mmc_active,
NULL);
}
}
return 0;
}
static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
{
int ret;
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
struct mmc_host *host = card->host;
unsigned long flags;
unsigned int cmd_flags = req ? req->cmd_flags : 0;
if (req && !mq->mqrq_prev->req) {
mmc_rpm_hold(host, &card->dev);
#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
if (mmc_bus_needs_resume(card->host)) {
mmc_resume_bus(card->host);
// mmc_blk_set_blksize(md, card);
}
#endif
/* claim host only for the first request */
mmc_claim_host(card->host);
if (card->ext_csd.bkops_en)
mmc_stop_bkops(card);
}
ret = mmc_blk_part_switch(card, md);
if (ret) {
if (req) {
blk_end_request_all(req, -EIO);
}
ret = 0;
goto out;
}
mmc_blk_write_packing_control(mq, req);
clear_bit(MMC_QUEUE_NEW_REQUEST, &mq->flags);
clear_bit(MMC_QUEUE_URGENT_REQUEST, &mq->flags);
if (cmd_flags & REQ_SANITIZE) {
/* complete ongoing async transfer before issuing sanitize */
if (card->host && card->host->areq)
mmc_blk_issue_rw_rq(mq, NULL);
ret = mmc_blk_issue_sanitize_rq(mq, req);
} else if (cmd_flags & REQ_DISCARD) {
/* complete ongoing async transfer before issuing discard */
if (card->host->areq)
mmc_blk_issue_rw_rq(mq, NULL);
if (cmd_flags & REQ_SECURE &&
!(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
ret = mmc_blk_issue_secdiscard_rq(mq, req);
else
ret = mmc_blk_issue_discard_rq(mq, req);
} else if (cmd_flags & REQ_FLUSH) {
/* complete ongoing async transfer before issuing flush */
if (card->host->areq)
mmc_blk_issue_rw_rq(mq, NULL);
ret = mmc_blk_issue_flush(mq, req);
} else {
if (!req && host->areq) {
spin_lock_irqsave(&host->context_info.lock, flags);
host->context_info.is_waiting_last_req = true;
spin_unlock_irqrestore(&host->context_info.lock, flags);
}
ret = mmc_blk_issue_rw_rq(mq, req);
}
out:
/*
* packet burst is over, when one of the following occurs:
* - no more requests and new request notification is not in progress
* - urgent notification in progress and current request is not urgent
* (all existing requests completed or reinserted to the block layer)
*/
if ((!req && !(test_bit(MMC_QUEUE_NEW_REQUEST, &mq->flags))) ||
((test_bit(MMC_QUEUE_URGENT_REQUEST, &mq->flags)) &&
!(cmd_flags & MMC_REQ_NOREINSERT_MASK))) {
if (mmc_card_need_bkops(card))
mmc_start_bkops(card, false);
/* release host only when there are no more requests */
mmc_release_host(card->host);
mmc_rpm_release(host, &card->dev);
}
return ret;
}
static inline int mmc_blk_readonly(struct mmc_card *card)
{
return mmc_card_readonly(card) ||
!(card->csd.cmdclass & CCC_BLOCK_WRITE);
}
static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
struct device *parent,
sector_t size,
bool default_ro,
const char *subname,
int area_type)
{
struct mmc_blk_data *md;
int devidx, ret;
unsigned int percentage =
BKOPS_SIZE_PERCENTAGE_TO_QUEUE_DELAYED_WORK;
devidx = find_first_zero_bit(dev_use, max_devices);
if (devidx >= max_devices)
return ERR_PTR(-ENOSPC);
__set_bit(devidx, dev_use);
md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL);
if (!md) {
ret = -ENOMEM;
goto out;
}
/*
* !subname implies we are creating main mmc_blk_data that will be
* associated with mmc_card with mmc_set_drvdata. Due to device
* partitions, devidx will not coincide with a per-physical card
* index anymore so we keep track of a name index.
*/
if (!subname) {
md->name_idx = find_first_zero_bit(name_use, max_devices);
__set_bit(md->name_idx, name_use);
} else
md->name_idx = ((struct mmc_blk_data *)
dev_to_disk(parent)->private_data)->name_idx;
md->area_type = area_type;
/*
* Set the read-only status based on the supported commands
* and the write protect switch.
*/
md->read_only = mmc_blk_readonly(card);
md->disk = alloc_disk(perdev_minors);
if (md->disk == NULL) {
ret = -ENOMEM;
goto err_kfree;
}
spin_lock_init(&md->lock);
INIT_LIST_HEAD(&md->part);
md->usage = 1;
ret = mmc_init_queue(&md->queue, card, &md->lock, subname);
if (ret)
goto err_putdisk;
md->queue.issue_fn = mmc_blk_issue_rq;
md->queue.data = md;
md->disk->major = MMC_BLOCK_MAJOR;
md->disk->first_minor = devidx * perdev_minors;
md->disk->fops = &mmc_bdops;
md->disk->private_data = md;
md->disk->queue = md->queue.queue;
md->disk->driverfs_dev = parent;
set_disk_ro(md->disk, md->read_only || default_ro);
md->disk->flags = GENHD_FL_EXT_DEVT;
if (area_type & MMC_BLK_DATA_AREA_RPMB)
md->disk->flags |= GENHD_FL_NO_PART_SCAN;
/*
* As discussed on lkml, GENHD_FL_REMOVABLE should:
*
* - be set for removable media with permanent block devices
* - be unset for removable block devices with permanent media
*
* Since MMC block devices clearly fall under the second
* case, we do not set GENHD_FL_REMOVABLE. Userspace
* should use the block device creation/destruction hotplug
* messages to tell when the card is present.
*/
snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
"mmcblk%d%s", md->name_idx, subname ? subname : "");
blk_queue_logical_block_size(md->queue.queue, 512);
set_capacity(md->disk, size);
card->bkops_info.size_percentage_to_queue_delayed_work = percentage;
card->bkops_info.min_sectors_to_queue_delayed_work =
((unsigned int)size * percentage) / 100;
if (mmc_host_cmd23(card->host)) {
if (mmc_card_mmc(card) ||
(mmc_card_sd(card) &&
card->scr.cmds & SD_SCR_CMD23_SUPPORT &&
mmc_sd_card_uhs(card)))
md->flags |= MMC_BLK_CMD23;
}
if (mmc_card_mmc(card) &&
md->flags & MMC_BLK_CMD23 &&
((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
card->ext_csd.rel_sectors)) {
md->flags |= MMC_BLK_REL_WR;
blk_queue_flush(md->queue.queue, REQ_FLUSH | REQ_FUA);
}
return md;
err_putdisk:
put_disk(md->disk);
err_kfree:
if (!subname)
__clear_bit(md->name_idx, name_use);
kfree(md);
out:
__clear_bit(devidx, dev_use);
return ERR_PTR(ret);
}
static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
{
sector_t size;
struct mmc_blk_data *md;
if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) {
/*
* The EXT_CSD sector count is in number or 512 byte
* sectors.
*/
size = card->ext_csd.sectors;
} else {
/*
* The CSD capacity field is in units of read_blkbits.
* set_capacity takes units of 512 bytes.
*/
size = card->csd.capacity << (card->csd.read_blkbits - 9);
}
md = mmc_blk_alloc_req(card, &card->dev, size, false, NULL,
MMC_BLK_DATA_AREA_MAIN);
return md;
}
static int mmc_blk_alloc_part(struct mmc_card *card,
struct mmc_blk_data *md,
unsigned int part_type,
sector_t size,
bool default_ro,
const char *subname,
int area_type)
{
char cap_str[10];
struct mmc_blk_data *part_md;
part_md = mmc_blk_alloc_req(card, disk_to_dev(md->disk), size, default_ro,
subname, area_type);
if (IS_ERR(part_md))
return PTR_ERR(part_md);
part_md->part_type = part_type;
list_add(&part_md->part, &md->part);
string_get_size((u64)get_capacity(part_md->disk) << 9, STRING_UNITS_2,
cap_str, sizeof(cap_str));
pr_info("%s: %s %s partition %u %s\n",
part_md->disk->disk_name, mmc_card_id(card),
mmc_card_name(card), part_md->part_type, cap_str);
return 0;
}
/* MMC Physical partitions consist of two boot partitions and
* up to four general purpose partitions.
* For each partition enabled in EXT_CSD a block device will be allocatedi
* to provide access to the partition.
*/
static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md)
{
int idx, ret = 0;
if (!mmc_card_mmc(card))
return 0;
for (idx = 0; idx < card->nr_parts; idx++) {
if (card->part[idx].size) {
ret = mmc_blk_alloc_part(card, md,
card->part[idx].part_cfg,
card->part[idx].size >> 9,
card->part[idx].force_ro,
card->part[idx].name,
card->part[idx].area_type);
if (ret)
return ret;
}
}
return ret;
}
static void mmc_blk_remove_req(struct mmc_blk_data *md)
{
struct mmc_card *card;
if (md) {
card = md->queue.card;
device_remove_file(disk_to_dev(md->disk),
&md->num_wr_reqs_to_start_packing);
if (md->disk->flags & GENHD_FL_UP) {
device_remove_file(disk_to_dev(md->disk), &md->force_ro);
if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) &&
card->ext_csd.boot_ro_lockable)
device_remove_file(disk_to_dev(md->disk),
&md->power_ro_lock);
/* Stop new requests from getting into the queue */
del_gendisk(md->disk);
}
/* Then flush out any already in there */
mmc_cleanup_queue(&md->queue);
mmc_blk_put(md);
}
}
static void mmc_blk_remove_parts(struct mmc_card *card,
struct mmc_blk_data *md)
{
struct list_head *pos, *q;
struct mmc_blk_data *part_md;
__clear_bit(md->name_idx, name_use);
list_for_each_safe(pos, q, &md->part) {
part_md = list_entry(pos, struct mmc_blk_data, part);
list_del(pos);
mmc_blk_remove_req(part_md);
}
}
static int mmc_add_disk(struct mmc_blk_data *md)
{
int ret;
struct mmc_card *card = md->queue.card;
add_disk(md->disk);
md->force_ro.show = force_ro_show;
md->force_ro.store = force_ro_store;
sysfs_attr_init(&md->force_ro.attr);
md->force_ro.attr.name = "force_ro";
md->force_ro.attr.mode = S_IRUGO | S_IWUSR;
ret = device_create_file(disk_to_dev(md->disk), &md->force_ro);
if (ret)
goto force_ro_fail;
if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) &&
card->ext_csd.boot_ro_lockable) {
umode_t mode;
if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_DIS)
mode = S_IRUGO;
else
mode = S_IRUGO | S_IWUSR;
md->power_ro_lock.show = power_ro_lock_show;
md->power_ro_lock.store = power_ro_lock_store;
sysfs_attr_init(&md->power_ro_lock.attr);
md->power_ro_lock.attr.mode = mode;
md->power_ro_lock.attr.name =
"ro_lock_until_next_power_on";
ret = device_create_file(disk_to_dev(md->disk),
&md->power_ro_lock);
if (ret)
goto power_ro_lock_fail;
}
md->num_wr_reqs_to_start_packing.show =
num_wr_reqs_to_start_packing_show;
md->num_wr_reqs_to_start_packing.store =
num_wr_reqs_to_start_packing_store;
sysfs_attr_init(&md->num_wr_reqs_to_start_packing.attr);
md->num_wr_reqs_to_start_packing.attr.name =
"num_wr_reqs_to_start_packing";
md->num_wr_reqs_to_start_packing.attr.mode = S_IRUGO | S_IWUSR;
ret = device_create_file(disk_to_dev(md->disk),
&md->num_wr_reqs_to_start_packing);
if (ret)
goto num_wr_reqs_to_start_packing_fail;
md->bkops_check_threshold.show = bkops_check_threshold_show;
md->bkops_check_threshold.store = bkops_check_threshold_store;
sysfs_attr_init(&md->bkops_check_threshold.attr);
md->bkops_check_threshold.attr.name = "bkops_check_threshold";
md->bkops_check_threshold.attr.mode = S_IRUGO | S_IWUSR;
ret = device_create_file(disk_to_dev(md->disk),
&md->bkops_check_threshold);
if (ret)
goto bkops_check_threshold_fails;
md->no_pack_for_random.show = no_pack_for_random_show;
md->no_pack_for_random.store = no_pack_for_random_store;
sysfs_attr_init(&md->no_pack_for_random.attr);
md->no_pack_for_random.attr.name = "no_pack_for_random";
md->no_pack_for_random.attr.mode = S_IRUGO | S_IWUSR;
ret = device_create_file(disk_to_dev(md->disk),
&md->no_pack_for_random);
if (ret)
goto no_pack_for_random_fails;
return ret;
no_pack_for_random_fails:
device_remove_file(disk_to_dev(md->disk),
&md->bkops_check_threshold);
bkops_check_threshold_fails:
device_remove_file(disk_to_dev(md->disk),
&md->num_wr_reqs_to_start_packing);
num_wr_reqs_to_start_packing_fail:
device_remove_file(disk_to_dev(md->disk), &md->power_ro_lock);
power_ro_lock_fail:
device_remove_file(disk_to_dev(md->disk), &md->force_ro);
force_ro_fail:
del_gendisk(md->disk);
return ret;
}
#define CID_MANFID_SANDISK 0x2
#define CID_MANFID_TOSHIBA 0x11
#define CID_MANFID_MICRON 0x13
#define CID_MANFID_SAMSUNG 0x15
#define CID_MANFID_HYNIX 0x90
static const struct mmc_fixup blk_fixups[] =
{
MMC_FIXUP("SEM02G", CID_MANFID_SANDISK, 0x100, add_quirk,
MMC_QUIRK_INAND_CMD38),
MMC_FIXUP("SEM04G", CID_MANFID_SANDISK, 0x100, add_quirk,
MMC_QUIRK_INAND_CMD38),
MMC_FIXUP("SEM08G", CID_MANFID_SANDISK, 0x100, add_quirk,
MMC_QUIRK_INAND_CMD38),
MMC_FIXUP("SEM16G", CID_MANFID_SANDISK, 0x100, add_quirk,
MMC_QUIRK_INAND_CMD38),
MMC_FIXUP("SEM32G", CID_MANFID_SANDISK, 0x100, add_quirk,
MMC_QUIRK_INAND_CMD38),
/*
* Some MMC cards experience performance degradation with CMD23
* instead of CMD12-bounded multiblock transfers. For now we'll
* black list what's bad...
* - Certain Toshiba cards.
*
* N.B. This doesn't affect SD cards.
*/
MMC_FIXUP("MMC08G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_BLK_NO_CMD23),
MMC_FIXUP("MMC16G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_BLK_NO_CMD23),
MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_BLK_NO_CMD23),
/*
* Some Micron MMC cards needs longer data read timeout than
* indicated in CSD.
*/
MMC_FIXUP(CID_NAME_ANY, CID_MANFID_MICRON, 0x200, add_quirk_mmc,
MMC_QUIRK_LONG_READ_TIME),
/* Some INAND MCP devices advertise incorrect timeout values */
MMC_FIXUP("SEM04G", 0x45, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_INAND_DATA_TIMEOUT),
/*
* On these Samsung MoviNAND parts, performing secure erase or
* secure trim can result in unrecoverable corruption due to a
* firmware bug.
*/
MMC_FIXUP("M8G2FA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("MAG4FA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("MBG8FA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("MCGAFA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("VAL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("VYL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("KYL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("VZL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP(CID_NAME_ANY, CID_MANFID_HYNIX, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_BROKEN_DATA_TIMEOUT),
/*
* On these Samsung MoviNAND parts, performing secure erase or
* secure trim can result in unrecoverable corruption due to a
* firmware bug.
*/
MMC_FIXUP("M8G2FA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("MAG4FA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("MBG8FA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("MCGAFA", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("VAL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("VYL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("KYL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
MMC_FIXUP("VZL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
END_FIXUP
};
#ifdef CONFIG_MMC_SUPPORT_BKOPS_MODE
static ssize_t bkops_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gendisk *disk;
struct mmc_blk_data *md;
struct mmc_card *card;
disk = dev_to_disk(dev);
if (disk)
md = disk->private_data;
else
goto show_out;
if (md)
card = md->queue.card;
else
goto show_out;
return snprintf(buf, PAGE_SIZE, "%u\n", card->bkops_enable);
show_out:
return snprintf(buf, PAGE_SIZE, "\n");
}
static ssize_t bkops_mode_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct gendisk *disk;
struct mmc_blk_data *md;
struct mmc_card *card;
u8 value;
int err = 0;
disk = dev_to_disk(dev);
if (disk)
md = disk->private_data;
else
goto store_out;
if (md)
card = md->queue.card;
else
goto store_out;
if (kstrtou8(buf, 0, &value))
goto store_out;
err = mmc_bkops_enable(card->host, value);
if (err)
return err;
return count;
store_out:
return -EINVAL;
}
static inline void mmc_blk_bkops_sysfs_init(struct mmc_card *card)
{
struct mmc_blk_data *md = mmc_get_drvdata(card);
card->bkops_attr.show = bkops_mode_show;
card->bkops_attr.store = bkops_mode_store;
sysfs_attr_init(&card->bkops_attr.attr);
card->bkops_attr.attr.name = "bkops_en";
card->bkops_attr.attr.mode = S_IRUGO | S_IWUSR | S_IWGRP;
if (device_create_file((disk_to_dev(md->disk)), &card->bkops_attr)) {
pr_err("%s: Failed to create bkops_en sysfs entry\n",
mmc_hostname(card->host));
#if defined(CONFIG_MMC_BKOPS_NODE_UID) || defined(CONFIG_MMC_BKOPS_NODE_GID)
} else {
int rc;
struct device * dev;
dev = disk_to_dev(md->disk);
rc = sysfs_chown_file(&dev->kobj, &card->bkops_attr.attr,
CONFIG_MMC_BKOPS_NODE_UID,
CONFIG_MMC_BKOPS_NODE_GID);
if (rc)
pr_err("%s: Failed to change mode of sysfs entry\n",
mmc_hostname(card->host));
#endif
}
}
#else
static inline void mmc_blk_bkops_sysfs_init(struct mmc_card *card)
{
}
#endif
static int mmc_blk_probe(struct mmc_card *card)
{
struct mmc_blk_data *md, *part_md;
char cap_str[10];
/*
* Check that the card supports the command class(es) we need.
*/
if (!(card->csd.cmdclass & CCC_BLOCK_READ))
return -ENODEV;
md = mmc_blk_alloc(card);
if (IS_ERR(md))
return PTR_ERR(md);
string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2,
cap_str, sizeof(cap_str));
pr_info("[%s]%s: %s %s %s %s, card->type:%d\n", __func__,
md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
cap_str, md->read_only ? "(ro)" : "", card->type);
if (mmc_blk_alloc_parts(card, md))
goto out;
mmc_set_drvdata(card, md);
mmc_fixup_device(card, blk_fixups);
#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
/*applying only MMC TYPE, need more time to verify SD TYPE*/
if (card && mmc_card_mmc(card))
mmc_set_bus_resume_policy(card->host, 1);
#endif
if (mmc_add_disk(md))
goto out;
list_for_each_entry(part_md, &md->part, part) {
if (mmc_add_disk(part_md))
goto out;
}
/* init sysfs for bkops mode */
if (card && mmc_card_mmc(card)) {
mmc_blk_bkops_sysfs_init(card);
spin_lock_init(&card->bkops_lock);
}
return 0;
out:
mmc_blk_remove_parts(card, md);
mmc_blk_remove_req(md);
return 0;
}
static void mmc_blk_remove(struct mmc_card *card)
{
struct mmc_blk_data *md = mmc_get_drvdata(card);
mmc_blk_remove_parts(card, md);
mmc_claim_host(card->host);
mmc_blk_part_switch(card, md);
mmc_release_host(card->host);
mmc_blk_remove_req(md);
mmc_set_drvdata(card, NULL);
#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
mmc_set_bus_resume_policy(card->host, 0);
#endif
}
static void mmc_blk_shutdown(struct mmc_card *card)
{
struct mmc_blk_data *part_md;
struct mmc_blk_data *md = mmc_get_drvdata(card);
int rc;
/* Silent the block layer */
if (md) {
rc = mmc_queue_suspend(&md->queue, 1);
if (rc)
goto suspend_error;
list_for_each_entry(part_md, &md->part, part) {
rc = mmc_queue_suspend(&part_md->queue, 1);
if (rc)
goto suspend_error;
}
}
/* send power off notification */
if (mmc_card_mmc(card)) {
mmc_rpm_hold(card->host, &card->dev);
mmc_claim_host(card->host);
mmc_stop_bkops(card);
mmc_release_host(card->host);
mmc_send_long_pon(card);
mmc_rpm_release(card->host, &card->dev);
}
return;
suspend_error:
pr_err("%s: mmc_queue_suspend returned error = %d",
mmc_hostname(card->host), rc);
}
#ifdef CONFIG_PM
static int mmc_blk_suspend(struct mmc_card *card)
{
struct mmc_blk_data *part_md;
struct mmc_blk_data *md = mmc_get_drvdata(card);
int rc = 0;
if (md) {
rc = mmc_queue_suspend(&md->queue, 0);
if (rc)
goto out;
list_for_each_entry(part_md, &md->part, part) {
rc = mmc_queue_suspend(&part_md->queue, 0);
if (rc)
goto out_resume;
}
}
goto out;
out_resume:
mmc_queue_resume(&md->queue);
list_for_each_entry(part_md, &md->part, part) {
mmc_queue_resume(&part_md->queue);
}
out:
return rc;
}
static int mmc_blk_resume(struct mmc_card *card)
{
struct mmc_blk_data *part_md;
struct mmc_blk_data *md = mmc_get_drvdata(card);
if (md) {
/*
* Resume involves the card going into idle state,
* so current partition is always the main one.
*/
md->part_curr = md->part_type;
mmc_queue_resume(&md->queue);
list_for_each_entry(part_md, &md->part, part) {
mmc_queue_resume(&part_md->queue);
}
}
return 0;
}
#else
#define mmc_blk_suspend NULL
#define mmc_blk_resume NULL
#endif
static struct mmc_driver mmc_driver = {
.drv = {
.name = "mmcblk",
},
.probe = mmc_blk_probe,
.remove = mmc_blk_remove,
.suspend = mmc_blk_suspend,
.resume = mmc_blk_resume,
.shutdown = mmc_blk_shutdown,
};
static int __init mmc_blk_init(void)
{
int res;
if (perdev_minors != CONFIG_MMC_BLOCK_MINORS)
pr_info("mmcblk: using %d minors per device\n", perdev_minors);
max_devices = 256 / perdev_minors;
res = register_blkdev(MMC_BLOCK_MAJOR, "mmc");
if (res)
goto out;
res = mmc_register_driver(&mmc_driver);
if (res)
goto out2;
return 0;
out2:
unregister_blkdev(MMC_BLOCK_MAJOR, "mmc");
out:
return res;
}
static void __exit mmc_blk_exit(void)
{
mmc_unregister_driver(&mmc_driver);
unregister_blkdev(MMC_BLOCK_MAJOR, "mmc");
}
module_init(mmc_blk_init);
module_exit(mmc_blk_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver");
|
googyanas/Googy-Max4-Kernel
|
drivers/mmc/card/block.c
|
C
|
gpl-2.0
| 94,946 |
<html>
<head>
<title>RunUO Documentation - Class Overview - SaveMetrics</title>
</head>
<body bgcolor="white" style="font-family: Courier New" text="#000000" link="#000000" vlink="#000000" alink="#808080">
<h4><a href="../namespaces/Server.html">Back to Server</a></h4>
<h2>SaveMetrics : <!-- DBG-2.1 --><font color="blue">IDisposable</font></h2>
(<font color="blue">ctor</font>) SaveMetrics()<br>
<font color="blue">virtual</font> <font color="blue">void</font> Dispose()<br>
<font color="blue">void</font> OnFileWritten( <font color="blue">int</font> numberOfBytes )<br>
<font color="blue">void</font> OnGuildSaved( <font color="blue">int</font> numberOfBytes )<br>
<font color="blue">void</font> OnItemSaved( <font color="blue">int</font> numberOfBytes )<br>
<font color="blue">void</font> OnMobileSaved( <font color="blue">int</font> numberOfBytes )<br>
</body>
</html>
|
alucardxlx/caoticamente-shards
|
docs/types/SaveMetrics.html
|
HTML
|
gpl-2.0
| 955 |
#ifndef __OAL_HCC_H__
#define __OAL_HCC_H__
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
/*****************************************************************************
1 ÆäËûÍ·Îļþ°üº¬
*****************************************************************************/
#if (SUB_SYSTEM == SUB_SYS_BFG)
#include "bfgn_msg_manage.h"
#endif
/*****************************************************************************
2 ºê¶¨Òå
*****************************************************************************/
/*****************************************************************************
3 ö¾Ù¶¨Òå
*****************************************************************************/
/*****************************************************************************
4 È«¾Ö±äÁ¿ÉùÃ÷
*****************************************************************************/
/*****************************************************************************
5 ÏûϢͷ¶¨Òå
*****************************************************************************/
/*****************************************************************************
6 ÏûÏ¢¶¨Òå
*****************************************************************************/
/*****************************************************************************
7 STRUCT¶¨Òå
*****************************************************************************/
/*****************************************************************************
8 UNION¶¨Òå
*****************************************************************************/
/*****************************************************************************
9 OTHERS¶¨Òå
*****************************************************************************/
/*****************************************************************************
10 º¯ÊýÉùÃ÷
*****************************************************************************/
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif /* end of oal_hcc.h */
|
Honor8Dev/android_kernel_huawei_FRD-L04
|
drivers/connectivity/hisi/c02/platform/inc/oal/oal_hcc.h
|
C
|
gpl-2.0
| 2,016 |
# Opus/UrbanSim urban simulation software.
# Copyright (C) 2005-2009 University of Washington
# See opus_core/LICENSE
from opus_core.variables.variable import Variable
from variable_functions import my_attribute_label
from urbansim.functions import attribute_label
class gc_ln_access_to_workplace_from_residences(Variable):
"""Looks up the variable with the same name that is in zone. """
zn_ln_access_to_workplaces_from_residences = "ln_access_to_workplace_from_residences"
def dependencies(self):
return [my_attribute_label("zone_id"),
attribute_label("zone", self.zn_ln_access_to_workplaces_from_residences)]
def compute(self, dataset_pool):
zones = dataset_pool.get_dataset('zone')
return self.get_dataset().get_join_data(zones, name=self.zn_ln_access_to_workplaces_from_residences)
from opus_core.tests import opus_unittest
from opus_core.tests.utils.variable_tester import VariableTester
from numpy import array
class Tests(opus_unittest.OpusTestCase):
def test_my_inputs(self):
zone_id = array([1, 1, 3, 2])
tffjth = array([4.1, 5.3, 6.2])
tester = VariableTester(
__file__,
package_order=['urbansim'],
test_data={
"gridcell":{
"grid_id":array([1,2,3,4]),
"zone_id":zone_id
},
"zone":{
"zone_id":array([1,2,3]),
"ln_access_to_workplace_from_residences": tffjth
}
}
)
should_be = array([4.1, 4.1, 6.2, 5.3])
tester.test_is_close_for_variable_defined_by_this_module(self, should_be)
if __name__=='__main__':
opus_unittest.main()
|
christianurich/VIBe2UrbanSim
|
3rdparty/opus/src/urbansim/gridcell/gc_ln_access_to_workplace_from_residences.py
|
Python
|
gpl-2.0
| 1,824 |
/**
* @file
* Representation of an email address
*
* @authors
* Copyright (C) 1996-2000,2011-2013 Michael R. Elkins <[email protected]>
* Copyright (C) 2017 Richard Russon <[email protected]>
* Copyright (C) 2019 Pietro Cerutti <[email protected]>
*
* @copyright
* 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, see <http://www.gnu.org/licenses/>.
*/
/**
* @page addr_address Email address
*
* Representation of an email address
*/
#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "mutt/lib.h"
#include "address.h"
#include "idna2.h"
/**
* AddressSpecials - Characters with special meaning for email addresses
*/
const char AddressSpecials[] = "@.,:;<>[]\\\"()";
/**
* is_special - Is this character special to an email address?
* @param ch Character
*/
#define is_special(ch) strchr(AddressSpecials, ch)
/**
* AddressError - An out-of-band error code
*
* Many of the Address functions set this variable on error.
* Its values are defined in #AddressError.
* Text for the errors can be looked up using #AddressErrors.
*/
int AddressError = 0;
/**
* AddressErrors - Messages for the error codes in #AddressError
*
* These must defined in the same order as enum AddressError.
*/
const char *const AddressErrors[] = {
"out of memory", "mismatched parentheses", "mismatched quotes",
"bad route in <>", "bad address in <>", "bad address spec",
};
/**
* parse_comment - Extract a comment (parenthesised string)
* @param[in] s String, just after the opening parenthesis
* @param[out] comment Buffer to store parenthesised string
* @param[out] commentlen Length of parenthesised string
* @param[in] commentmax Length of buffer
* @retval ptr First character after parenthesised string
* @retval NULL Error
*/
static const char *parse_comment(const char *s, char *comment, size_t *commentlen, size_t commentmax)
{
int level = 1;
while (*s && level)
{
if (*s == '(')
level++;
else if (*s == ')')
{
if (--level == 0)
{
s++;
break;
}
}
else if (*s == '\\')
{
if (!*++s)
break;
}
if (*commentlen < commentmax)
comment[(*commentlen)++] = *s;
s++;
}
if (level != 0)
{
AddressError = ADDR_ERR_MISMATCH_PAREN;
return NULL;
}
return s;
}
/**
* parse_quote - Extract a quoted string
* @param[in] s String, just after the opening quote mark
* @param[out] token Buffer to store quoted string
* @param[out] tokenlen Length of quoted string
* @param[in] tokenmax Length of buffer
* @retval ptr First character after quoted string
* @retval NULL Error
*/
static const char *parse_quote(const char *s, char *token, size_t *tokenlen, size_t tokenmax)
{
while (*s)
{
if (*tokenlen < tokenmax)
token[*tokenlen] = *s;
if (*s == '\\')
{
if (!*++s)
break;
if (*tokenlen < tokenmax)
token[*tokenlen] = *s;
}
else if (*s == '"')
return s + 1;
(*tokenlen)++;
s++;
}
AddressError = ADDR_ERR_MISMATCH_QUOTE;
return NULL;
}
/**
* next_token - Find the next word, skipping quoted and parenthesised text
* @param[in] s String to search
* @param[out] token Buffer for the token
* @param[out] tokenlen Length of the next token
* @param[in] tokenmax Length of the buffer
* @retval ptr First character after the next token
*/
static const char *next_token(const char *s, char *token, size_t *tokenlen, size_t tokenmax)
{
if (*s == '(')
return parse_comment(s + 1, token, tokenlen, tokenmax);
if (*s == '"')
return parse_quote(s + 1, token, tokenlen, tokenmax);
if (*s && is_special(*s))
{
if (*tokenlen < tokenmax)
token[(*tokenlen)++] = *s;
return s + 1;
}
while (*s)
{
if (mutt_str_is_email_wsp(*s) || is_special(*s))
break;
if (*tokenlen < tokenmax)
token[(*tokenlen)++] = *s;
s++;
}
return s;
}
/**
* parse_mailboxdomain - Extract part of an email address (and a comment)
* @param[in] s String to parse
* @param[in] nonspecial Specific characters that are valid
* @param[out] mailbox Buffer for email address
* @param[out] mailboxlen Length of saved email address
* @param[in] mailboxmax Length of mailbox buffer
* @param[out] comment Buffer for comment
* @param[out] commentlen Length of saved comment
* @param[in] commentmax Length of comment buffer
* @retval ptr First character after the email address part
*
* This will be called twice to parse an email address, first for the mailbox
* name, then for the domain name. Each part can also have a comment in `()`.
* The comment can be at the start or end of the mailbox or domain.
*
* Examples:
* - "[email protected]"
* - "john.doe(comment)@example.com"
* - "[email protected](comment)"
*
* The first call will return "john.doe" with optional comment, "comment".
* The second call will return "example.com" with optional comment, "comment".
*/
static const char *parse_mailboxdomain(const char *s, const char *nonspecial,
char *mailbox, size_t *mailboxlen,
size_t mailboxmax, char *comment,
size_t *commentlen, size_t commentmax)
{
const char *ps = NULL;
while (*s)
{
s = mutt_str_skip_email_wsp(s);
if ((*s == '\0'))
return s;
if (!strchr(nonspecial, *s) && is_special(*s))
return s;
if (*s == '(')
{
if (*commentlen && (*commentlen < commentmax))
comment[(*commentlen)++] = ' ';
ps = next_token(s, comment, commentlen, commentmax);
}
else
ps = next_token(s, mailbox, mailboxlen, mailboxmax);
if (!ps)
return NULL;
s = ps;
}
return s;
}
/**
* parse_address - Extract an email address
* @param[in] s String, just after the opening `<`
* @param[out] token Buffer for the email address
* @param[out] tokenlen Length of the email address
* @param[in] tokenmax Length of the email address buffer
* @param[out] comment Buffer for any comments
* @param[out] commentlen Length of any comments
* @param[in] commentmax Length of the comment buffer
* @param[in] addr Address to store the results
* @retval ptr The closing `>` of the email address
* @retval NULL Error
*/
static const char *parse_address(const char *s, char *token, size_t *tokenlen,
size_t tokenmax, char *comment, size_t *commentlen,
size_t commentmax, struct Address *addr)
{
s = parse_mailboxdomain(s, ".\"(\\", token, tokenlen, tokenmax, comment,
commentlen, commentmax);
if (!s)
return NULL;
if (*s == '@')
{
if (*tokenlen < tokenmax)
token[(*tokenlen)++] = '@';
s = parse_mailboxdomain(s + 1, ".([]\\", token, tokenlen, tokenmax, comment,
commentlen, commentmax);
if (!s)
return NULL;
}
terminate_string(token, *tokenlen, tokenmax);
addr->mailbox = mutt_str_dup(token);
if (*commentlen && !addr->personal)
{
terminate_string(comment, *commentlen, commentmax);
addr->personal = mutt_str_dup(comment);
}
return s;
}
/**
* parse_route_addr - Parse an email addresses
* @param[in] s String, just after the opening `<`
* @param[out] comment Buffer for any comments
* @param[out] commentlen Length of any comments
* @param[in] commentmax Length of the comments buffer
* @param[in] addr Address to store the details
* @retval ptr First character after the email address
*/
static const char *parse_route_addr(const char *s, char *comment, size_t *commentlen,
size_t commentmax, struct Address *addr)
{
char token[1024];
size_t tokenlen = 0;
s = mutt_str_skip_email_wsp(s);
/* find the end of the route */
if (*s == '@')
{
while (s && (*s == '@'))
{
if (tokenlen < (sizeof(token) - 1))
token[tokenlen++] = '@';
s = parse_mailboxdomain(s + 1, ",.\\[](", token, &tokenlen,
sizeof(token) - 1, comment, commentlen, commentmax);
}
if (!s || (*s != ':'))
{
AddressError = ADDR_ERR_BAD_ROUTE;
return NULL; /* invalid route */
}
if (tokenlen < (sizeof(token) - 1))
token[tokenlen++] = ':';
s++;
}
s = parse_address(s, token, &tokenlen, sizeof(token) - 1, comment, commentlen,
commentmax, addr);
if (!s)
return NULL;
if (*s != '>')
{
AddressError = ADDR_ERR_BAD_ROUTE_ADDR;
return NULL;
}
if (!addr->mailbox)
addr->mailbox = mutt_str_dup("@");
s++;
return s;
}
/**
* parse_addr_spec - Parse an email address
* @param[in] s String to parse
* @param[out] comment Buffer for any comments
* @param[out] commentlen Length of any comments
* @param[in] commentmax Length of the comments buffer
* @param[in] addr Address to fill in
* @retval ptr First character after the email address
*/
static const char *parse_addr_spec(const char *s, char *comment, size_t *commentlen,
size_t commentmax, struct Address *addr)
{
char token[1024];
size_t tokenlen = 0;
s = parse_address(s, token, &tokenlen, sizeof(token) - 1, comment, commentlen,
commentmax, addr);
if (s && *s && (*s != ',') && (*s != ';'))
{
AddressError = ADDR_ERR_BAD_ADDR_SPEC;
return NULL;
}
return s;
}
/**
* add_addrspec - Parse an email address and add an Address to a list
* @param[out] al Address list
* @param[in] phrase String to parse
* @param[out] comment Buffer for any comments
* @param[out] commentlen Length of any comments
* @param[in] commentmax Length of the comments buffer
* @retval true An address was successfully parsed and added
*/
static bool add_addrspec(struct AddressList *al, const char *phrase,
char *comment, size_t *commentlen, size_t commentmax)
{
struct Address *cur = mutt_addr_new();
if (!parse_addr_spec(phrase, comment, commentlen, commentmax, cur))
{
mutt_addr_free(&cur);
return false;
}
mutt_addrlist_append(al, cur);
return true;
}
/**
* mutt_addr_new - Create a new Address
* @retval ptr Newly allocated Address
*
* Free the result with mutt_addr_free()
*/
struct Address *mutt_addr_new(void)
{
return mutt_mem_calloc(1, sizeof(struct Address));
}
/**
* mutt_addr_create - Create and populate a new Address
* @param[in] personal The personal name for the Address (can be NULL)
* @param[in] mailbox The mailbox for the Address (can be NULL)
* @retval ptr Newly allocated Address
* @note The personal and mailbox values, if not NULL, are going to be copied
* into the newly allocated Address.
*/
struct Address *mutt_addr_create(const char *personal, const char *mailbox)
{
struct Address *a = mutt_addr_new();
a->personal = mutt_str_dup(personal);
a->mailbox = mutt_str_dup(mailbox);
return a;
}
/**
* mutt_addrlist_remove - Remove an Address from a list
* @param[in,out] al AddressList
* @param[in] mailbox Email address to match
* @retval 0 Success
* @retval -1 Error, or email not found
*/
int mutt_addrlist_remove(struct AddressList *al, const char *mailbox)
{
if (!al)
return -1;
if (!mailbox)
return 0;
int rc = -1;
struct Address *a = NULL, *tmp = NULL;
TAILQ_FOREACH_SAFE(a, al, entries, tmp)
{
if (mutt_istr_equal(mailbox, a->mailbox))
{
TAILQ_REMOVE(al, a, entries);
mutt_addr_free(&a);
rc = 0;
}
}
return rc;
}
/**
* mutt_addr_free - Free a single Address
* @param[out] ptr Address to free
*/
void mutt_addr_free(struct Address **ptr)
{
if (!ptr || !*ptr)
return;
struct Address *a = *ptr;
FREE(&a->personal);
FREE(&a->mailbox);
FREE(ptr);
}
/**
* mutt_addrlist_parse - Parse a list of email addresses
* @param al AddressList to append addresses
* @param s String to parse
* @retval num Number of parsed addresses
*/
int mutt_addrlist_parse(struct AddressList *al, const char *s)
{
if (!s)
return 0;
int parsed = 0;
char comment[1024], phrase[1024];
size_t phraselen = 0, commentlen = 0;
AddressError = 0;
bool ws_pending = mutt_str_is_email_wsp(*s);
s = mutt_str_skip_email_wsp(s);
while (*s)
{
switch (*s)
{
case ';':
case ',':
if (phraselen != 0)
{
terminate_buffer(phrase, phraselen);
if (add_addrspec(al, phrase, comment, &commentlen, sizeof(comment) - 1))
{
parsed++;
}
}
else if (commentlen != 0)
{
struct Address *last = TAILQ_LAST(al, AddressList);
if (last && !last->personal && last->mailbox)
{
terminate_buffer(comment, commentlen);
last->personal = mutt_str_dup(comment);
}
}
if (*s == ';')
{
/* add group terminator */
mutt_addrlist_append(al, mutt_addr_new());
}
phraselen = 0;
commentlen = 0;
s++;
break;
case '(':
if ((commentlen != 0) && (commentlen < (sizeof(comment) - 1)))
comment[commentlen++] = ' ';
s = next_token(s, comment, &commentlen, sizeof(comment) - 1);
if (!s)
{
mutt_addrlist_clear(al);
return 0;
}
break;
case '"':
if ((phraselen != 0) && (phraselen < (sizeof(phrase) - 1)))
phrase[phraselen++] = ' ';
s = parse_quote(s + 1, phrase, &phraselen, sizeof(phrase) - 1);
if (!s)
{
mutt_addrlist_clear(al);
return 0;
}
break;
case ':':
{
struct Address *a = mutt_addr_new();
terminate_buffer(phrase, phraselen);
a->mailbox = mutt_str_dup(phrase);
a->group = true;
mutt_addrlist_append(al, a);
phraselen = 0;
commentlen = 0;
s++;
break;
}
case '<':
{
struct Address *a = mutt_addr_new();
terminate_buffer(phrase, phraselen);
a->personal = mutt_str_dup(phrase);
s = parse_route_addr(s + 1, comment, &commentlen, sizeof(comment) - 1, a);
if (!s)
{
mutt_addrlist_clear(al);
mutt_addr_free(&a);
return 0;
}
mutt_addrlist_append(al, a);
phraselen = 0;
commentlen = 0;
parsed++;
break;
}
default:
if ((phraselen != 0) && (phraselen < (sizeof(phrase) - 1)) && ws_pending)
phrase[phraselen++] = ' ';
if (*s == '\\')
{
s++;
if (*s && (phraselen < (sizeof(phrase) - 1)))
{
phrase[phraselen++] = *s;
s++;
}
}
s = next_token(s, phrase, &phraselen, sizeof(phrase) - 1);
if (!s)
{
mutt_addrlist_clear(al);
return 0;
}
break;
} // switch (*s)
ws_pending = mutt_str_is_email_wsp(*s);
s = mutt_str_skip_email_wsp(s);
} // while (*s)
if (phraselen != 0)
{
terminate_buffer(phrase, phraselen);
terminate_buffer(comment, commentlen);
if (add_addrspec(al, phrase, comment, &commentlen, sizeof(comment) - 1))
{
parsed++;
}
}
else if (commentlen != 0)
{
struct Address *last = TAILQ_LAST(al, AddressList);
if (last && !last->personal && last->mailbox)
{
terminate_buffer(comment, commentlen);
last->personal = mutt_str_dup(comment);
}
}
return parsed;
}
/**
* mutt_addrlist_parse2 - Parse a list of email addresses
* @param al Add to this List of Addresses
* @param s String to parse
* @retval num Number of parsed addresses
*
* Simple email addresses (without any personal name or grouping) can be
* separated by whitespace or commas.
*/
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
{
if (!s || (*s == '\0'))
return 0;
int parsed = 0;
/* check for a simple whitespace separated list of addresses */
if (!strpbrk(s, "\"<>():;,\\"))
{
char *copy = mutt_str_dup(s);
char *r = copy;
while ((r = strtok(r, " \t")))
{
parsed += mutt_addrlist_parse(al, r);
r = NULL;
}
FREE(©);
}
else
parsed = mutt_addrlist_parse(al, s);
return parsed;
}
/**
* mutt_addrlist_qualify - Expand local names in an Address list using a hostname
* @param al Address list
* @param host Hostname
*
* Any addresses containing a bare name will be expanded using the hostname.
* e.g. "john", "example.com" -> '[email protected]'. This function has no
* effect if host is NULL or the empty string.
*/
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
{
if (!al || !host || (*host == '\0'))
return;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
if (!a->group && a->mailbox && !strchr(a->mailbox, '@'))
{
char *p = mutt_mem_malloc(mutt_str_len(a->mailbox) + mutt_str_len(host) + 2);
sprintf(p, "%s@%s", a->mailbox, host);
FREE(&a->mailbox);
a->mailbox = p;
}
}
}
/**
* mutt_addr_cat - Copy a string and wrap it in quotes if it contains special characters
* @param buf Buffer for the result
* @param buflen Length of the result buffer
* @param value String to copy
* @param specials Characters to lookup
*
* This function copies the string in the "value" parameter in the buffer
* pointed to by "buf" parameter. If the input string contains any of the
* characters specified in the "specials" parameters, the output string is
* wrapped in double quoted. Additionally, any backslashes or quotes inside the
* input string are backslash-escaped.
*/
void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials)
{
if (!buf || !value || !specials)
return;
if (strpbrk(value, specials))
{
char tmp[256];
char *pc = tmp;
size_t tmplen = sizeof(tmp) - 3;
*pc++ = '"';
for (; *value && (tmplen > 1); value++)
{
if ((*value == '\\') || (*value == '"'))
{
*pc++ = '\\';
tmplen--;
}
*pc++ = *value;
tmplen--;
}
*pc++ = '"';
*pc = '\0';
mutt_str_copy(buf, tmp, buflen);
}
else
mutt_str_copy(buf, value, buflen);
}
/**
* mutt_addr_copy - Copy the real address
* @param addr Address to copy
* @retval ptr New Address
*/
struct Address *mutt_addr_copy(const struct Address *addr)
{
if (!addr)
return NULL;
struct Address *p = mutt_addr_new();
p->personal = mutt_str_dup(addr->personal);
p->mailbox = mutt_str_dup(addr->mailbox);
p->group = addr->group;
p->is_intl = addr->is_intl;
p->intl_checked = addr->intl_checked;
return p;
}
/**
* mutt_addrlist_copy - Copy a list of addresses into another list
* @param dst Destination Address list
* @param src Source Address list
* @param prune Skip groups if there are more addresses
*/
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
{
if (!dst || !src)
return;
struct Address *a = NULL;
TAILQ_FOREACH(a, src, entries)
{
struct Address *next = TAILQ_NEXT(a, entries);
if (prune && a->group && (!next || !next->mailbox))
{
/* ignore this element of the list */
}
else
{
mutt_addrlist_append(dst, mutt_addr_copy(a));
}
}
}
/**
* mutt_addr_valid_msgid - Is this a valid Message ID?
* @param msgid Message ID
* @retval true It is a valid message ID
*
* Incomplete. Only used to thwart the APOP MD5 attack
*/
bool mutt_addr_valid_msgid(const char *msgid)
{
/* msg-id = "<" addr-spec ">"
* addr-spec = local-part "@" domain
* local-part = word *("." word)
* word = atom / quoted-string
* atom = 1*<any CHAR except specials, SPACE and CTLs>
* CHAR = ( 0.-127. )
* specials = "(" / ")" / "<" / ">" / "@"
* / "," / ";" / ":" / "\" / <">
* / "." / "[" / "]"
* SPACE = ( 32. )
* CTLS = ( 0.-31., 127.)
* quoted-string = <"> *(qtext/quoted-pair) <">
* qtext = <any CHAR except <">, "\" and CR>
* CR = ( 13. )
* quoted-pair = "\" CHAR
* domain = sub-domain *("." sub-domain)
* sub-domain = domain-ref / domain-literal
* domain-ref = atom
* domain-literal = "[" *(dtext / quoted-pair) "]"
*/
if (!msgid || (*msgid == '\0'))
return false;
size_t l = mutt_str_len(msgid);
if (l < 5) /* <atom@atom> */
return false;
if ((msgid[0] != '<') || (msgid[l - 1] != '>'))
return false;
if (!(strrchr(msgid, '@')))
return false;
/* TODO: complete parser */
for (size_t i = 0; i < l; i++)
if ((unsigned char) msgid[i] > 127)
return false;
return true;
}
/**
* mutt_addrlist_equal - Compare two Address lists for equality
* @param ala First Address
* @param alb Second Address
* @retval true Address lists are strictly identical
*/
bool mutt_addrlist_equal(const struct AddressList *ala, const struct AddressList *alb)
{
if (!ala || !alb)
{
return !(ala || alb);
}
struct Address *ana = TAILQ_FIRST(ala);
struct Address *anb = TAILQ_FIRST(alb);
while (ana && anb)
{
if (!mutt_str_equal(ana->mailbox, anb->mailbox) ||
!mutt_str_equal(ana->personal, anb->personal))
{
break;
}
ana = TAILQ_NEXT(ana, entries);
anb = TAILQ_NEXT(anb, entries);
}
return !(ana || anb);
}
/**
* mutt_addrlist_count_recips - Count the number of Addresses with valid recipients
* @param al Address list
* @retval num Number of valid Addresses
*
* An Address has a recipient if the mailbox is set and is not a group
*/
int mutt_addrlist_count_recips(const struct AddressList *al)
{
if (!al)
return 0;
int c = 0;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
c += (a->mailbox && !a->group);
}
return c;
}
/**
* mutt_addr_cmp - Compare two e-mail addresses
* @param a Address 1
* @param b Address 2
* @retval true They are equivalent
*/
bool mutt_addr_cmp(const struct Address *a, const struct Address *b)
{
if (!a || !b)
return false;
if (!a->mailbox || !b->mailbox)
return false;
if (!mutt_istr_equal(a->mailbox, b->mailbox))
return false;
return true;
}
/**
* mutt_addrlist_search - Search for an e-mail address in a list
* @param haystack Address List
* @param needle Address containing the search email
* @retval true The Address is in the list
*/
bool mutt_addrlist_search(const struct AddressList *haystack, const struct Address *needle)
{
if (!needle || !haystack)
return false;
struct Address *a = NULL;
TAILQ_FOREACH(a, haystack, entries)
{
if (mutt_addr_cmp(needle, a))
return true;
}
return false;
}
/**
* addr_is_intl - Does the Address have IDN components
* @param a Address to check
* @retval true Address contains IDN components
*/
static bool addr_is_intl(const struct Address *a)
{
if (!a)
return false;
return a->intl_checked && a->is_intl;
}
/**
* addr_is_local - Does the Address have NO IDN components
* @param a Address to check
* @retval true Address contains NO IDN components
*/
static bool addr_is_local(const struct Address *a)
{
if (!a)
return false;
return a->intl_checked && !a->is_intl;
}
/**
* addr_mbox_to_udomain - Split a mailbox name into user and domain
* @param[in] mbox Mailbox name to split
* @param[out] user User
* @param[out] domain Domain
* @retval 0 Success
* @retval -1 Error
*
* @warning The caller must free user and domain
*/
static int addr_mbox_to_udomain(const char *mbox, char **user, char **domain)
{
if (!mbox || !user || !domain)
return -1;
char *ptr = strchr(mbox, '@');
/* Fail if '@' is missing, at the start, or at the end */
if (!ptr || (ptr == mbox) || (ptr[1] == '\0'))
return -1;
*user = mutt_strn_dup(mbox, ptr - mbox);
*domain = mutt_str_dup(ptr + 1);
return 0;
}
/**
* addr_set_intl - Mark an Address as having IDN components
* @param a Address to modify
* @param intl_mailbox Email address with IDN components
*/
static void addr_set_intl(struct Address *a, char *intl_mailbox)
{
if (!a)
return;
FREE(&a->mailbox);
a->mailbox = intl_mailbox;
a->intl_checked = true;
a->is_intl = true;
}
/**
* addr_set_local - Mark an Address as having NO IDN components
* @param a Address
* @param local_mailbox Email address with NO IDN components
*/
static void addr_set_local(struct Address *a, char *local_mailbox)
{
if (!a)
return;
FREE(&a->mailbox);
a->mailbox = local_mailbox;
a->intl_checked = true;
a->is_intl = false;
}
/**
* mutt_addr_for_display - Convert an Address for display purposes
* @param a Address to convert
* @retval ptr Address to display
*
* @warning This function may return a static pointer. It must not be freed by
* the caller. Later calls may overwrite the returned pointer.
*/
const char *mutt_addr_for_display(const struct Address *a)
{
if (!a)
return NULL;
char *user = NULL, *domain = NULL;
static char *buf = NULL;
if (!a->mailbox || addr_is_local(a))
return a->mailbox;
if (addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1)
return a->mailbox;
char *local_mailbox = mutt_idna_intl_to_local(user, domain, MI_MAY_BE_IRREVERSIBLE);
FREE(&user);
FREE(&domain);
if (!local_mailbox)
return a->mailbox;
mutt_str_replace(&buf, local_mailbox);
FREE(&local_mailbox);
return buf;
}
/**
* mutt_addr_write - Write a single Address to a buffer
* @param buf Buffer for the Address
* @param buflen Length of the buffer
* @param addr Address to display
* @param display This address will be displayed to the user
* @retval num Length of the string written to buf
*
* If 'display' is set, then it doesn't matter if the transformation isn't
* reversible.
*/
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
{
if (!buf || (buflen == 0) || !addr)
return 0;
if (!addr->personal && !addr->mailbox)
return 0;
size_t len;
char *pbuf = buf;
char *pc = NULL;
buflen--; /* save room for the terminal nul */
if (addr->personal)
{
if (strpbrk(addr->personal, AddressSpecials))
{
if (buflen == 0)
goto done;
*pbuf++ = '"';
buflen--;
for (pc = addr->personal; *pc && (buflen > 0); pc++)
{
if ((*pc == '"') || (*pc == '\\'))
{
*pbuf++ = '\\';
buflen--;
}
if (buflen == 0)
goto done;
*pbuf++ = *pc;
buflen--;
}
if (buflen == 0)
goto done;
*pbuf++ = '"';
buflen--;
}
else
{
if (buflen == 0)
goto done;
len = mutt_str_copy(pbuf, addr->personal, buflen + 1);
pbuf += len;
buflen -= len;
}
if (buflen == 0)
goto done;
*pbuf++ = ' ';
buflen--;
}
if (addr->personal || (addr->mailbox && (*addr->mailbox == '@')))
{
if (buflen == 0)
goto done;
*pbuf++ = '<';
buflen--;
}
if (addr->mailbox)
{
if (buflen == 0)
goto done;
if (mutt_str_equal(addr->mailbox, "@"))
{
*pbuf = '\0';
}
else
{
const char *a = display ? mutt_addr_for_display(addr) : addr->mailbox;
len = mutt_str_copy(pbuf, a, buflen + 1);
pbuf += len;
buflen -= len;
}
if (addr->personal || (addr->mailbox && (*addr->mailbox == '@')))
{
if (buflen == 0)
goto done;
*pbuf++ = '>';
buflen--;
}
if (addr->group)
{
if (buflen == 0)
goto done;
*pbuf++ = ':';
buflen--;
if (buflen == 0)
goto done;
*pbuf++ = ' ';
buflen--;
}
}
else
{
if (buflen == 0)
goto done;
*pbuf++ = ';';
}
done:
/* no need to check for length here since we already save space at the
* beginning of this routine */
*pbuf = '\0';
return pbuf - buf;
}
/**
* mutt_addrlist_write - Write an Address to a buffer
* @param al AddressList to display
* @param buf Buffer for the Address
* @param buflen Length of the buffer
* @param display This address will be displayed to the user
* @retval num Length of the string written to buf
*
* If 'display' is set, then it doesn't matter if the transformation isn't
* reversible.
*
* @note It is assumed that `buf` is nul terminated!
*/
size_t mutt_addrlist_write(const struct AddressList *al, char *buf, size_t buflen, bool display)
{
if (!buf || (buflen == 0) || !al)
return 0;
size_t len = mutt_str_len(buf);
if (len >= buflen)
{
return 0;
}
char *pbuf = buf + len;
buflen -= len;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
if (len > 0)
{
if (buflen > 1)
{
*pbuf++ = ',';
buflen--;
}
if (buflen > 1)
{
*pbuf++ = ' ';
buflen--;
}
}
if (buflen == 1)
{
break;
}
len = mutt_addr_write(pbuf, buflen, a, display);
pbuf += len;
buflen -= len;
}
*pbuf = '\0';
return pbuf - buf;
}
/**
* mutt_addrlist_write_list - Write Addresses to a List
* @param al AddressList to write
* @param list List for the Addresses
* @retval num Number of addresses written
*/
size_t mutt_addrlist_write_list(const struct AddressList *al, struct ListHead *list)
{
if (!al || !list)
return 0;
char addr[256];
size_t count = 0;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
if (mutt_addr_write(addr, sizeof(addr), a, true) != 0)
{
mutt_list_insert_tail(list, strdup(addr));
count++;
}
}
return count;
}
/**
* mutt_addrlist_write_file - Wrapper for mutt_write_address()
* @param al Address list
* @param fp File to write to
* @param start_col Starting column in the output line
* @param display True if these addresses will be displayed to the user
*
* So we can handle very large recipient lists without needing a huge temporary
* buffer in memory
*/
void mutt_addrlist_write_file(const struct AddressList *al, FILE *fp, int start_col, bool display)
{
char buf[1024];
int count = 0;
int linelen = start_col;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
buf[0] = '\0';
size_t len = mutt_addr_write(buf, sizeof(buf), a, display);
if (len == 0)
continue;
if (count && (linelen + len > 74))
{
fputs("\n\t", fp);
linelen = len + 8; /* tab is usually about 8 spaces... */
}
else
{
if (count && a->mailbox)
{
fputc(' ', fp);
linelen++;
}
linelen += len;
}
fputs(buf, fp);
struct Address *next = TAILQ_NEXT(a, entries);
if (!a->group && next && next->mailbox)
{
linelen++;
fputc(',', fp);
}
count++;
}
fputc('\n', fp);
}
/**
* mutt_addr_to_intl - Convert an Address to Punycode
* @param a Address to convert
* @retval true Success
* @retval false Otherwise
*/
bool mutt_addr_to_intl(struct Address *a)
{
if (!a || !a->mailbox || addr_is_intl(a))
return true;
char *user = NULL;
char *domain = NULL;
if (addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1)
return true;
char *intl_mailbox = mutt_idna_local_to_intl(user, domain);
FREE(&user);
FREE(&domain);
if (!intl_mailbox)
return false;
addr_set_intl(a, intl_mailbox);
return true;
}
/**
* mutt_addrlist_to_intl - Convert an Address list to Punycode
* @param[in] al Address list to modify
* @param[out] err Pointer for failed addresses
* @retval 0 Success, all addresses converted
* @retval -1 Error, err will be set to the failed address
*/
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
{
if (!al)
return 0;
int rc = 0;
if (err)
*err = NULL;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
if (!a->mailbox || addr_is_intl(a))
continue;
char *user = NULL;
char *domain = NULL;
if (addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1)
continue;
char *intl_mailbox = mutt_idna_local_to_intl(user, domain);
FREE(&user);
FREE(&domain);
if (!intl_mailbox)
{
rc = -1;
if (err && !*err)
*err = mutt_str_dup(a->mailbox);
continue;
}
addr_set_intl(a, intl_mailbox);
}
return rc;
}
/**
* mutt_addr_to_local - Convert an Address from Punycode
* @param a Address to convert
* @retval true Success
* @retval false Otherwise
*/
bool mutt_addr_to_local(struct Address *a)
{
if (!a->mailbox)
{
return false;
}
if (addr_is_local(a))
{
return true;
}
char *user = NULL;
char *domain = NULL;
if (addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1)
{
return false;
}
char *local_mailbox = mutt_idna_intl_to_local(user, domain, MI_NO_FLAGS);
FREE(&user);
FREE(&domain);
if (!local_mailbox)
{
return false;
}
addr_set_local(a, local_mailbox);
return true;
}
/**
* mutt_addrlist_to_local - Convert an Address list from Punycode
* @param al Address list to modify
* @retval 0 Always
*/
int mutt_addrlist_to_local(struct AddressList *al)
{
if (!al)
return 0;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
mutt_addr_to_local(a);
}
return 0;
}
/**
* mutt_addrlist_dedupe - Remove duplicate addresses
* @param al Address list to de-dupe
*
* Given a list of addresses, return a list of unique addresses
*/
void mutt_addrlist_dedupe(struct AddressList *al)
{
if (!al)
return;
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
if (a->mailbox)
{
struct Address *a2 = TAILQ_NEXT(a, entries);
struct Address *tmp = NULL;
if (a2)
{
TAILQ_FOREACH_FROM_SAFE(a2, al, entries, tmp)
{
if (a2->mailbox && mutt_istr_equal(a->mailbox, a2->mailbox))
{
mutt_debug(LL_DEBUG2, "Removing %s\n", a2->mailbox);
TAILQ_REMOVE(al, a2, entries);
mutt_addr_free(&a2);
}
}
}
}
}
}
/**
* mutt_addrlist_remove_xrefs - Remove cross-references
* @param a Reference AddressList
* @param b AddressLis to trim
*
* Remove addresses from "b" which are contained in "a"
*/
void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b)
{
if (!a || !b)
return;
struct Address *aa = NULL, *ab = NULL, *tmp = NULL;
TAILQ_FOREACH_SAFE(ab, b, entries, tmp)
{
TAILQ_FOREACH(aa, a, entries)
{
if (mutt_addr_cmp(aa, ab))
{
TAILQ_REMOVE(b, ab, entries);
mutt_addr_free(&ab);
break;
}
}
}
}
/**
* mutt_addrlist_clear - Unlink and free all Address in an AddressList
* @param al AddressList
*
* @note After this call, the AddressList is reinitialized and ready for reuse.
*/
void mutt_addrlist_clear(struct AddressList *al)
{
if (!al)
return;
struct Address *a = TAILQ_FIRST(al), *next = NULL;
while (a)
{
next = TAILQ_NEXT(a, entries);
mutt_addr_free(&a);
a = next;
}
TAILQ_INIT(al);
}
/**
* mutt_addrlist_append - Append an Address to an AddressList
* @param al AddressList
* @param a Address
*/
void mutt_addrlist_append(struct AddressList *al, struct Address *a)
{
if (al && a)
TAILQ_INSERT_TAIL(al, a, entries);
}
/**
* mutt_addrlist_prepend - Prepend an Address to an AddressList
* @param al AddressList
* @param a Address
*/
void mutt_addrlist_prepend(struct AddressList *al, struct Address *a)
{
if (al && a)
TAILQ_INSERT_HEAD(al, a, entries);
}
/**
* mutt_addr_uses_unicode - Does this address use Unicode character
* @param str Address string to check
* @retval true The string uses 8-bit characters
*/
bool mutt_addr_uses_unicode(const char *str)
{
if (!str)
return false;
while (*str)
{
if ((unsigned char) *str & (1 << 7))
return true;
str++;
}
return false;
}
/**
* mutt_addrlist_uses_unicode - Do any of a list of addresses use Unicode characters
* @param al Address list to check
* @retval true Any use 8-bit characters
*/
bool mutt_addrlist_uses_unicode(const struct AddressList *al)
{
if (!al)
{
return false;
}
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
if (a->mailbox && !a->group && mutt_addr_uses_unicode(a->mailbox))
return true;
}
return false;
}
|
flatcap/neomutt
|
address/address.c
|
C
|
gpl-2.0
| 37,260 |
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\Core\Persistence;
use eZ\Publish\Core\Persistence\TransformationProcessor\PcreCompiler;
/**
* Interface for processing a set of transformations on a string.
*/
abstract class TransformationProcessor
{
const T_COMMENT = 1;
const T_WHITESPACE = 2;
const T_SECTION = 10;
const T_MAP = 11;
const T_REPLACE = 12;
const T_TRANSPOSE = 13;
const T_TRANSPOSE_MODULO = 14;
/**
* Parsed rule files.
*
* @var array
*/
protected $ruleFiles = [];
/**
* Compiled rules, which can directly be applied to the input strings.
*
* @var array
*/
protected $compiledRules = null;
/**
* Transformation compiler.
*
* @var \eZ\Publish\Core\Persistence\TransformationProcessor\PcreCompiler
*/
protected $compiler = null;
/**
* Construct instance of TransformationProcessor.
*
* Through the $ruleFiles array, a list of files with full text
* transformation rules is given.
*
* @param \eZ\Publish\Core\Persistence\TransformationProcessor\PcreCompiler $compiler
* @param array $ruleFiles
*/
public function __construct(PcreCompiler $compiler, array $ruleFiles = [])
{
$this->ruleFiles = $ruleFiles;
$this->compiler = $compiler;
}
/**
* Loads rules.
*
* @return array
*/
abstract protected function getRules();
/**
* Transform the given string.
*
* Transform the given string using the given rules. If no rules are
* specified, all available rules will be used for the transformation.
*
* @param string $string
* @param array $ruleNames
*
* @return string
*/
public function transform($string, array $ruleNames = [])
{
$rules = $this->getRules();
foreach ($ruleNames ?: array_keys($rules) as $ruleName) {
if (!isset($rules[$ruleName])) {
// Just continue on unknown rules, or should we throw an error
// here?
continue;
}
foreach ($rules[$ruleName] as $rule) {
$string = preg_replace_callback(
$rule['regexp'],
$rule['callback'],
$string
);
}
}
return $string;
}
/**
* Transform the given string by group.
*
* Transform the given string using a rule group.
*
* @param string $string
* @param string $ruleGroup
*
* @return string
*/
public function transformByGroup($string, $ruleGroup)
{
$rules = $this->getRules();
foreach (array_keys($rules) as $ruleName) {
if (strpos($ruleName, $ruleGroup) === false) {
continue;
}
foreach ($rules[$ruleName] as $rule) {
$string = preg_replace_callback(
$rule['regexp'],
$rule['callback'],
$string
);
}
}
return $string;
}
}
|
ezsystems/ezpublish-kernel
|
eZ/Publish/Core/Persistence/TransformationProcessor.php
|
PHP
|
gpl-2.0
| 3,304 |
/*
* Copyright 2002-2006, project beam (http://sourceforge.net/projects/beam).
* All rights reserved. Distributed under the terms of the GNU GPL v2.
*
* Authors:
* Oliver Tappe <[email protected]>
*/
#ifndef _BmCheckControl_h
#define _BmCheckControl_h
#include <MCheckBox.h>
#include "BmGuiBase.h"
class HGroup;
class IMPEXPBMGUIBASE BmCheckControl : public MCheckBox
{
typedef MCheckBox inherited;
public:
// creator-func, c'tors and d'tor:
BmCheckControl( const char* label, ulong id=0, bool state=false);
BmCheckControl( const char* label, BMessage* msg, BHandler* target=NULL, bool state=false);
~BmCheckControl();
// native methods:
float LabelWidth();
void AdjustToMaxLabelWidth( float maxWidth);
void SetValueSilently( bool val);
minimax layoutprefs();
private:
void _InitSize();
// Hide copy-constructor and assignment:
BmCheckControl( const BmCheckControl&);
BmCheckControl operator=( const BmCheckControl&);
};
#endif
|
olta/beam
|
src-bmGuiBase/BmCheckControl.h
|
C
|
gpl-2.0
| 966 |
# -*- coding: utf-8 -*-
#
#
# TheVirtualBrain-Scientific Package. This package holds all simulators, and
# analysers necessary to run brain-simulations. You can use it stand alone or
# in conjunction with TheVirtualBrain-Framework Package. See content of the
# documentation-folder for more details. See also http://www.thevirtualbrain.org
#
# (c) 2012-2013, Baycrest Centre for Geriatric Care ("Baycrest")
#
# 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. You should have received a copy of the GNU General
# Public License along with this program; if not, you can download it here
# http://www.gnu.org/licenses/old-licenses/gpl-2.0
#
#
# CITATION:
# When using The Virtual Brain for scientific publications, please cite it as follows:
#
# Paula Sanz Leon, Stuart A. Knock, M. Marmaduke Woodman, Lia Domide,
# Jochen Mersmann, Anthony R. McIntosh, Viktor Jirsa (2013)
# The Virtual Brain: a simulator of primate brain network dynamics.
# Frontiers in Neuroinformatics (7:10. doi: 10.3389/fninf.2013.00010)
#
#
"""
Explore LarterBreakspear model.
``Run time``: 20 min (workstation circa 2012 Intel Xeon [email protected])
``Memory requirement``: ~300 MB
``Storage requirement``: ~150MB
NOTE: stats were made for a simulation using the 998 region Hagmann
connectivity matrix.
.. moduleauthor:: Paula Sanz Leon <[email protected]>
"""
# Third party python libraries
import numpy
# Try and import from "The Virtual Brain"
from tvb.simulator.lab import *
from tvb.datatypes.time_series import TimeSeriesRegion
import tvb.analyzers.fmri_balloon as bold
from tvb.simulator.plot import timeseries_interactive as timeseries_interactive
##----------------------------------------------------------------------------##
##- Perform the simulation -##
##----------------------------------------------------------------------------##
LOG.info("Configuring...")
#Initialise a Model, Coupling, and Connectivity.
lb = models.LarterBreakspear(QV_max=1.0, QZ_max=1.0,
d_V=0.65, d_Z=0.65,
aee=0.36, ani=0.4, ane=1.0, C=0.1)
lb.variables_of_interest = ["V", "W", "Z"]
white_matter = connectivity.Connectivity(load_default=True)
white_matter.speed = numpy.array([7.0])
white_matter_coupling = coupling.HyperbolicTangent(a=0.5*lb.QV_max,
midpoint=lb.VT,
sigma=lb.d_V,
normalise=True)
#Initialise an Integrator
heunint = integrators.HeunDeterministic(dt=0.2)
#Initialise some Monitors with period in physical time
mon_tavg = monitors.TemporalAverage(period=2.)
mon_bold = monitors.Bold(period=2000.)
#Bundle them
what_to_watch = (mon_bold, mon_tavg)
#Initialise a Simulator -- Model, Connectivity, Integrator, and Monitors.
sim = simulator.Simulator(model = lb,
connectivity = white_matter,
coupling = white_matter_coupling,
integrator = heunint,
monitors = what_to_watch)
sim.configure()
LOG.info("Starting simulation...")
#Perform the simulation
bold_data, bold_time = [], []
tavg_data, tavg_time = [], []
for raw, tavg in sim(simulation_length=480000):
if not raw is None:
bold_time.append(raw[0])
bold_data.append(raw[1])
if not tavg is None:
tavg_time.append(tavg[0])
tavg_data.append(tavg[1])
LOG.info("Finished simulation.")
##----------------------------------------------------------------------------##
##- Plot pretty pictures of what we just did -##
##----------------------------------------------------------------------------##
#Make the lists numpy.arrays for easier use.
LOG.info("Converting result to array...")
TAVG_TIME = numpy.array(tavg_time)
BOLD_TIME = numpy.array(bold_time)
BOLD = numpy.array(bold_data)
TAVG = numpy.array(tavg_data)
#Create TimeSeries instance
tsr = TimeSeriesRegion(data = TAVG,
time = TAVG_TIME,
sample_period = 2.)
tsr.configure()
#Create and run the monitor/analyser
bold_model = bold.BalloonModel(time_series = tsr)
bold_data = bold_model.evaluate()
bold_tsr = TimeSeriesRegion(connectivity = white_matter,
data = bold_data.data,
time = bold_data.time)
#Prutty puctures...
tsi = timeseries_interactive.TimeSeriesInteractive(time_series = bold_tsr)
tsi.configure()
tsi.show()
###EoF###
|
rajul/tvb-library
|
tvb/simulator/demos/region_deterministic_larterbreakspear.py
|
Python
|
gpl-2.0
| 4,982 |
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM 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 Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
* $Id$
*
*/
class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form {
function __construct() {
$this->_columns = array(
'civicrm_contact' =>
array(
'dao' => 'CRM_Contact_DAO_Contact',
'fields' =>
array(
'sort_name' =>
array('title' => ts('Supporter'),
'required' => TRUE,
'default' => TRUE,
),
'id' =>
array(
'required' => TRUE,
'no_display' => TRUE,
),
'contact_type' =>
array(
'title' => ts('Supporter Contact Type'),
),
'contact_sub_type' =>
array(
'title' => ts('Supporter Contact SubType'),
),
),
'filters' =>
array(
'sort_name' =>
array('title' => ts('Supporter Name'),
'type' => CRM_Utils_Type::T_STRING,
'operator' => 'like',
),
'id' =>
array('title' => ts('Contact ID'),
'no_display' => TRUE,
),
),
'grouping' => 'pcp-fields',
),
'civicrm_contribution_page' =>
array(
'dao' => 'CRM_Contribute_DAO_ContributionPage',
'fields' =>
array(
'page_title' =>
array('title' => ts('Contribution Page Title'),
'name' => 'title',
'default' => TRUE,
),
),
'filters' =>
array(
'page_title' =>
array('title' => ts('Contribution Page Title'),
'name' => 'title',
'type' => CRM_Utils_Type::T_STRING,
),
),
'grouping' => 'pcp-fields',
),
'civicrm_pcp' =>
array(
'dao' => 'CRM_PCP_DAO_PCP',
'fields' =>
array(
'title' =>
array('title' => ts('Personal Campaign Title'),
'default' => TRUE,
),
'goal_amount' =>
array('title' => ts('Goal Amount'),
'type' => CRM_Utils_Type::T_MONEY,
'default' => TRUE,
),
),
'filters' =>
array(
'title' =>
array('title' => ts('Personal Campaign Title'),
'type' => CRM_Utils_Type::T_STRING,
),
),
'grouping' => 'pcp-fields',
),
'civicrm_contribution_soft' =>
array(
'dao' => 'CRM_Contribute_DAO_ContributionSoft',
'fields' =>
array(
'amount_1' =>
array('title' => ts('Committed Amount'),
'name' => 'amount',
'type' => CRM_Utils_Type::T_MONEY,
'default' => TRUE,
'statistics' =>
array('sum' => ts('Committed Amount'),
),
),
'amount_2' =>
array('title' => ts('Amount Received'),
'name' => 'amount',
'type' => CRM_Utils_Type::T_MONEY,
'default' => TRUE,
// nice trick with dbAlias
'dbAlias' => 'SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount))',
),
'soft_id' =>
array('title' => ts('Number of Donors'),
'name' => 'id',
'default' => TRUE,
'statistics' =>
array('count' => ts('Number of Donors'),
),
),
),
'filters' =>
array(
'amount_2' =>
array('title' => ts('Amount Received'),
'type' => CRM_Utils_Type::T_MONEY,
'dbAlias' => 'SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount))',
),
),
'grouping' => 'pcp-fields',
),
'civicrm_contribution' =>
array(
'dao' => 'CRM_Contribute_DAO_Contribution',
'fields' =>
array(
'contribution_id' =>
array(
'name' => 'id',
'no_display' => TRUE,
'required' => TRUE,
),
'receive_date' =>
array('title' => ts('Most Recent Donation'),
'default' => TRUE,
'statistics' =>
array('max' => ts('Most Recent Donation'),
),
),
),
'grouping' => 'pcp-fields',
),
);
parent::__construct();
}
function from() {
$this->_from = "
FROM civicrm_pcp {$this->_aliases['civicrm_pcp']}
LEFT JOIN civicrm_contribution_soft {$this->_aliases['civicrm_contribution_soft']}
ON {$this->_aliases['civicrm_pcp']}.id =
{$this->_aliases['civicrm_contribution_soft']}.pcp_id
LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
ON {$this->_aliases['civicrm_contribution_soft']}.contribution_id =
{$this->_aliases['civicrm_contribution']}.id
LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
ON {$this->_aliases['civicrm_pcp']}.contact_id =
{$this->_aliases['civicrm_contact']}.id
LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page']}
ON {$this->_aliases['civicrm_pcp']}.page_id =
{$this->_aliases['civicrm_contribution_page']}.id";
}
function groupBy() {
$this->_groupBy = "GROUP BY {$this->_aliases['civicrm_pcp']}.id";
}
function orderBy() {
$this->_orderBy = " ORDER BY {$this->_aliases['civicrm_contact']}.sort_name ";
}
function where() {
$whereClauses = $havingClauses = array();
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
$clause = NULL;
if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
$relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
$from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
$to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
$clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
}
else {
$op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
if ($op) {
$clause = $this->whereClause($field,
$op,
CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
);
}
}
if (!empty($clause)) {
if ($tableName == 'civicrm_contribution_soft' &&
$fieldName == 'amount_2'
) {
$havingClauses[] = $clause;
}
else {
$whereClauses[] = $clause;
}
}
}
}
}
if (empty($whereClauses)) {
$this->_where = "WHERE ( 1 ) ";
}
else {
$this->_where = "WHERE " . implode(' AND ', $whereClauses);
}
if ($this->_aclWhere) {
$this->_where .= " AND {$this->_aclWhere} ";
}
$this->_having = "";
if (!empty($havingClauses)) {
// use this clause to construct group by clause.
$this->_having = "HAVING " . implode(' AND ', $havingClauses);
}
}
function alterDisplay(&$rows) {
// custom code to alter rows
$entryFound = FALSE;
$checkList = array();
foreach ($rows as $rowNum => $row) {
if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') {
// not repeat contact sort names if it matches with the one
// in previous row
$repeatFound = FALSE;
foreach ($row as $colName => $colVal) {
if (CRM_Utils_Array::value($colName, $checkList) &&
is_array($checkList[$colName]) &&
in_array($colVal, $checkList[$colName])
) {
$rows[$rowNum][$colName] = "";
$repeatFound = TRUE;
}
if (in_array($colName, $this->_noRepeats)) {
$checkList[$colName][] = $colVal;
}
}
}
if (array_key_exists('civicrm_contact_sort_name', $row) &&
$rows[$rowNum]['civicrm_contact_sort_name'] &&
array_key_exists('civicrm_contact_id', $row)
) {
$url = CRM_Utils_System::url("civicrm/contact/view",
'reset=1&cid=' . $row['civicrm_contact_id'],
$this->_absoluteUrl
);
$rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
$entryFound = TRUE;
}
if (!$entryFound) {
break;
}
}
}
}
|
ChrisChinchilla/greenrenters.org
|
sites/all/modules/civicrm/CRM/Report/Form/Contribute/PCP.php
|
PHP
|
gpl-2.0
| 10,517 |
package de.unitrier.daalft.pali.morphology.strategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.unitrier.daalft.pali.morphology.element.ConstructedWord;
import de.unitrier.daalft.pali.morphology.element.FeatureSet;
import de.unitrier.daalft.pali.morphology.element.Morph;
import de.unitrier.daalft.pali.morphology.element.Morpheme;
import de.unitrier.daalft.pali.morphology.paradigm.Paradigm;
import de.unitrier.daalft.pali.morphology.paradigm.ParadigmAccessor;
import de.unitrier.daalft.pali.morphology.paradigm.irregular.IrregularNumerals;
import de.unitrier.daalft.pali.morphology.paradigm.rule.RightDeletingRule;
/**
* Pre-configured strategy for numerals
* @author David
*
*/
public class NumeralStrategy extends AbstractStrategy {
/**
* Irregular numerals 1-4
* and "ubho" (both)
*/
private static String[] a = {"eka", "dve", "ubho", "tayo", "cattāro"};
/**
* Irregular numerals 5-18
*/
private static String[] b = {
"pañca",
"cha",
"satta",
"aṭṭha",
"nava",
"dasa", "rasa", "lasa", "ḷasa", // spelling variation (10)
"akārasa", "ekādasa", // spelling variation (11)
"bārasa", "dvārasa", //...
"tedasa", "terasa", "telasa",
"catuddasa", "cuddasa", "coddasa",
"pañcadasa", "paṇṇarasa", "pannarasa",
"soḷasa", "sorasa",
"sattadasa", "sattarasa",
"aṭṭhādasa", "aṭṭhārasa"
};
private static List<String> oneToFour = Arrays.asList(a);
private static List<String> fiveTo18 = Arrays.asList(b);
public List<ConstructedWord> apply(String lemma, String... options) {
if (isOneToFour(lemma)) {
return oneToFourDec(lemma);
}
GeneralDeclensionStrategy gds = new GeneralDeclensionStrategy();
ParadigmAccessor pa = new ParadigmAccessor();
Paradigm num = pa.getNumeralParadigm();
Paradigm fte = num.getParadigmByFeatures(new FeatureSet("restriction", "5to18"));
Paradigm nu = num.getParadigmByFeatures(new FeatureSet("restriction", "19up"));
Paradigm fte_a = fte.getParadigmByFeatures(new FeatureSet("declension", "a"));
Paradigm nu_a = nu.getParadigmByFeatures(new FeatureSet("declension", "a"));
Paradigm nu_i = nu.getParadigmByFeatures(new FeatureSet("declension", "i"));
Paradigm nu_am = nu.getParadigmByFeatures(new FeatureSet("declension", "aṃ"));
List<ConstructedWord> out = new ArrayList<ConstructedWord>();
if (lemma.endsWith("a")) {
if (isFiveTo18(lemma)) {
out= gds.apply(lemma, fte_a, new RightDeletingRule(1));
} else if (is19up(lemma)) {
out= gds.apply(lemma, nu_a, new RightDeletingRule(1));
}
} else if (lemma.endsWith("i")) {
out= gds.apply(lemma, nu_i, new RightDeletingRule(1));
} else if (lemma.endsWith("aṃ")) {
out= gds.apply(lemma, nu_am, new RightDeletingRule(2));
}
// TODO include cardinals??
for (int i = 0; i < out.size(); i++) {
ConstructedWord cw = out.get(i);
cw.setLemma(lemma);
}
return out;
}
/**
* Checks whether the given lemma is a number from
* 1 to 4
* @param lemma lemma
* @return true if lemma is number word from 1 to 4
*/
private static boolean isOneToFour (String lemma) {
return oneToFour.contains(lemma);
}
/**
* Checks whether the given lemma is a number from
* 5 to 18
* @param lemma lemma
* @return true if lemma is number word from 5 to 18
*/
private static boolean isFiveTo18 (String lemma) {
return fiveTo18.contains(lemma);
}
/**
* Checks whether the given lemma is a number greater
* than 19
* @param lemma lemma
* @return true if lemma is number word greater than 19
*/
private static boolean is19up (String lemma) {
return !(oneToFour.contains(lemma)) && !(fiveTo18.contains(lemma));
}
/**
* Returns the declension of the number (1-4) specified by lemma
* @param lemma lemma
* @return morphological forms
*/
private List<ConstructedWord> oneToFourDec (String lemma) {
ParadigmAccessor pa = new ParadigmAccessor();
IrregularNumerals in = pa.getIrregularNumerals();
Paradigm p = in.getForms(lemma);
List<ConstructedWord> out = new ArrayList<ConstructedWord>();
for (Morpheme m : p.getMorphemes()) {
for (Morph n : m.getAllomorphs()) {
ConstructedWord cw = new ConstructedWord(n.getMorph(), m.getFeatureSet());
cw.setLemma(lemma);
out.add(cw);
}
}
return out;
}
/**
* Checks whether the given stem could be the
* stem of a number from 1 to 4
* @param stem stem
* @return true if stem could be number 1-4
*/
public static boolean isOneToFourStem (String stem) {
if (isOneToFour(stem))
return true;
for (String s : oneToFour) {
if (s.startsWith(stem) && (s.length() - stem.length() < 3))
return true;
}
return false;
}
/**
* Checks whether the given stem could be
* the stem of a number from 5 to 18
* @param stem stem
* @return true if stem could be number 5-18
*/
public static boolean isFiveTo18Stem (String stem) {
if (isFiveTo18(stem))
return true;
for (String s : fiveTo18) {
if (s.startsWith(stem) && (s.length() - stem.length() < 3))
return true;
}
return false;
}
/**
* Checks whether the given stem could be
* the stem of a number greater than 19
* @param stem stem
* @return true if stem could be number greater than 19
*/
public static boolean is19upStem (String stem) {
return (!isOneToFourStem(stem)) && (!isFiveTo18Stem(stem));
}
}
|
veer66/PaliNLP
|
src/de/unitrier/daalft/pali/morphology/strategy/NumeralStrategy.java
|
Java
|
gpl-2.0
| 5,374 |
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using agsXMPP;
using agsXMPP.protocol;
using agsXMPP.protocol.iq;
using agsXMPP.protocol.iq.disco;
using agsXMPP.protocol.iq.roster;
using agsXMPP.protocol.iq.version;
using agsXMPP.protocol.iq.oob;
using agsXMPP.protocol.client;
using agsXMPP.protocol.extensions.shim;
using agsXMPP.protocol.extensions.si;
using agsXMPP.protocol.extensions.bytestreams;
using agsXMPP.protocol.x;
using agsXMPP.protocol.x.data;
using agsXMPP.Xml;
using agsXMPP.Xml.Dom;
using agsXMPP.sasl;
using agsXMPP.ui;
using agsXMPP.ui.roster;
using System.Security.Cryptography;
using System.Text;
using agsXMPP.protocol.stream.feature.compression;
namespace MiniClient
{
/// <summary>
/// MainForm
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar statusBar1;
private System.ComponentModel.IContainer components;
private ContextMenuStrip contextMenuGC;
private ContextMenuStrip contextMenuStripRoster;
private ToolStripMenuItem chatToolStripMenuItem;
private ToolStripMenuItem vcardToolStripMenuItem;
private ToolStripMenuItem deleteToolStripMenuItem;
private MenuStrip menuStrip1;
private ToolStripMenuItem fileToolStripMenuItem;
private ToolStripMenuItem connectToolStripMenuItem;
private ToolStripMenuItem disconnectToolStripMenuItem;
private ToolStripSeparator toolStripMenuItem1;
private ToolStripMenuItem exitToolStripMenuItem;
private ToolStrip toolStrip1;
private ToolStripButton toolStripButtonAdd;
private ToolStripMenuItem joinToolStripMenuItem;
private XmppClientConnection XmppCon;
private ToolStripMenuItem sendFileToolStripMenuItem;
private ToolStripMenuItem executeToolStripMenuItem;
private ToolStripMenuItem configureToolStripMenuItem;
private ToolStripMenuItem executeToolStripMenuItem1;
private ToolStripMenuItem configureToolStripMenuItem1;
private XmppClientConnection ByteStreamCon;
private TabPage tabSocket;
private RichTextBox rtfDebugSocket;
private TabPage tabDebug;
private RichTextBox rtfDebug;
private TabPage tabGC;
private TreeView treeGC;
private ToolStrip ToolStripGC;
private ToolStripButton toolStripButtonFindRooms;
private ToolStripButton toolStripButtonFindPart;
private ToolStripButton toolStripButtonSearch;
private TabPage tabRoster;
private ComboBox cboStatus;
private TabControl tabControl1;
private ImageList ils16;
delegate void OnMessageDelegate(object sender, agsXMPP.protocol.client.Message msg);
delegate void OnPresenceDelegate(object sender, Presence pres);
const int IMAGE_PARTICIPANT = 3;
const int IMAGE_CHATROOM = 4;
private RosterControl rosterControl;
const int IMAGE_SERVER = 5;
public frmMain()
{
InitializeComponent();
treeGC.ContextMenuStrip = contextMenuGC;
// initialize Combo Status
cboStatus.Items.AddRange( new object[] {"offline",
ShowType.away.ToString(),
ShowType.xa.ToString(),
ShowType.chat.ToString(),
ShowType.dnd.ToString(),
"online" });
cboStatus.SelectedIndex = 0;
// initilaize XmppConnection
XmppCon = new XmppClientConnection();
ByteStreamCon = new XmppClientConnection();
XmppCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;
XmppCon.OnReadXml += new XmlHandler(XmppCon_OnReadXml);
XmppCon.OnWriteXml += new XmlHandler(XmppCon_OnWriteXml);
XmppCon.OnRosterStart += new ObjectHandler(XmppCon_OnRosterStart);
XmppCon.OnRosterEnd += new ObjectHandler(XmppCon_OnRosterEnd);
XmppCon.OnRosterItem += new agsXMPP.XmppClientConnection.RosterHandler(XmppCon_OnRosterItem);
XmppCon.OnAgentStart += new ObjectHandler(XmppCon_OnAgentStart);
XmppCon.OnAgentEnd += new ObjectHandler(XmppCon_OnAgentEnd);
XmppCon.OnAgentItem += new agsXMPP.XmppClientConnection.AgentHandler(XmppCon_OnAgentItem);
XmppCon.OnLogin += new ObjectHandler(XmppCon_OnLogin);
XmppCon.OnClose += new ObjectHandler(XmppCon_OnClose);
XmppCon.OnError += new ErrorHandler(XmppCon_OnError);
XmppCon.OnPresence += new PresenceHandler(XmppCon_OnPresence);
XmppCon.OnMessage += new MessageHandler(XmppCon_OnMessage);
XmppCon.OnIq += new IqHandler(XmppCon_OnIq);
XmppCon.OnAuthError += new XmppElementHandler(XmppCon_OnAuthError);
XmppCon.OnSocketError += new ErrorHandler(XmppCon_OnSocketError);
XmppCon.OnReadSocketData += new agsXMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnReceive);
XmppCon.OnWriteSocketData += new agsXMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnSend);
XmppCon.ClientSocket.OnValidateCertificate += new System.Net.Security.RemoteCertificateValidationCallback(ClientSocket_OnValidateCertificate);
XmppCon.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(XmppCon_OnXmppConnectionStateChanged);
XmppCon.OnSaslStart += new SaslEventHandler(XmppCon_OnSaslStart);
ByteStreamCon.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(XmppCon_OnXmppConnectionStateChanged);
ByteStreamCon.OnReadSocketData += new agsXMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnReceive);
ByteStreamCon.OnWriteSocketData += new agsXMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnSend);
LoadChatServers();
LoadSettings();
}
private void XmppCon_OnSocketError(object sender, Exception ex)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new ErrorHandler(XmppCon_OnSocketError), new object[] { sender, ex });
return;
}
MessageBox.Show("Socket Error\r\n" + ex.Message + "\r\n" + ex.InnerException);
}
private void LoadSettings()
{
string fileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
fileName += @"\Settings.xml";
Document doc = new Document();
if(doc.LoadFile(fileName))
{
Element Login = doc.RootElement.SelectSingleElement("Login");
Jid jid = new Jid(Login.GetTag("Jid"));
XmppCon.Server = jid.Server;
XmppCon.Username = jid.User;
XmppCon.Password = Login.GetTag("Password");
XmppCon.Resource = Login.GetTag("Resource");
XmppCon.Priority = Login.GetTagInt("Priority");
XmppCon.Port = Login.GetTagInt("Port");
XmppCon.UseSSL = Login.GetTagBool("Ssl");
XmppCon.AutoResolveConnectServer = true;
}
}
private void XmppCon_OnSaslStart(object sender, SaslEventArgs args)
{
// You can define the SASL mechanism here when needed, or implement your own SASL mechanisms
// for authentication
//args.Auto = false;
//args.Mechanism = agsXMPP.protocol.sasl.Mechanism.GetMechanismName(agsXMPP.protocol.sasl.MechanismType.PLAIN);
}
private void LoadChatServers()
{
treeGC.TreeViewNodeSorter = new TreeNodeSorter();
string fileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
fileName += @"\chatservers.xml";
Document doc = new Document();
doc.LoadFile(fileName);
// Get Servers
ElementList servers = doc.RootElement.SelectElements("Server");
foreach (Element server in servers)
{
TreeNode n = new TreeNode(server.Value);
n.Tag = "server";
n.ImageIndex = n.SelectedImageIndex = IMAGE_SERVER;
this.treeGC.Nodes.Add(n);
}
}
/// <summary>
///
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
///
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.contextMenuGC = new System.Windows.Forms.ContextMenuStrip(this.components);
this.joinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStripRoster = new System.Windows.Forms.ContextMenuStrip(this.components);
this.chatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.vcardToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sendFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.connectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.disconnectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripButtonAdd = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonSearch = new System.Windows.Forms.ToolStripButton();
this.executeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.configureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.executeToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.configureToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.tabSocket = new System.Windows.Forms.TabPage();
this.rtfDebugSocket = new System.Windows.Forms.RichTextBox();
this.tabDebug = new System.Windows.Forms.TabPage();
this.rtfDebug = new System.Windows.Forms.RichTextBox();
this.tabGC = new System.Windows.Forms.TabPage();
this.treeGC = new System.Windows.Forms.TreeView();
this.ils16 = new System.Windows.Forms.ImageList(this.components);
this.ToolStripGC = new System.Windows.Forms.ToolStrip();
this.toolStripButtonFindRooms = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonFindPart = new System.Windows.Forms.ToolStripButton();
this.tabRoster = new System.Windows.Forms.TabPage();
this.rosterControl = new agsXMPP.ui.roster.RosterControl();
this.cboStatus = new System.Windows.Forms.ComboBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.contextMenuGC.SuspendLayout();
this.contextMenuStripRoster.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.tabSocket.SuspendLayout();
this.tabDebug.SuspendLayout();
this.tabGC.SuspendLayout();
this.ToolStripGC.SuspendLayout();
this.tabRoster.SuspendLayout();
this.tabControl1.SuspendLayout();
this.SuspendLayout();
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 438);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(347, 24);
this.statusBar1.TabIndex = 1;
this.statusBar1.Text = "Offline";
//
// contextMenuGC
//
this.contextMenuGC.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.joinToolStripMenuItem});
this.contextMenuGC.Name = "contextMenuGC";
this.contextMenuGC.Size = new System.Drawing.Size(105, 26);
//
// joinToolStripMenuItem
//
this.joinToolStripMenuItem.Name = "joinToolStripMenuItem";
this.joinToolStripMenuItem.Size = new System.Drawing.Size(104, 22);
this.joinToolStripMenuItem.Text = "Join";
this.joinToolStripMenuItem.Click += new System.EventHandler(this.joinToolStripMenuItem_Click);
//
// contextMenuStripRoster
//
this.contextMenuStripRoster.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.chatToolStripMenuItem,
this.vcardToolStripMenuItem,
this.deleteToolStripMenuItem,
this.sendFileToolStripMenuItem});
this.contextMenuStripRoster.Name = "contextMenuStripRoster";
this.contextMenuStripRoster.Size = new System.Drawing.Size(129, 92);
//
// chatToolStripMenuItem
//
this.chatToolStripMenuItem.Image = global::MiniClient.Properties.Resources.comment;
this.chatToolStripMenuItem.Name = "chatToolStripMenuItem";
this.chatToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
this.chatToolStripMenuItem.Text = "chat";
this.chatToolStripMenuItem.Click += new System.EventHandler(this.chatToolStripMenuItem_Click);
//
// vcardToolStripMenuItem
//
this.vcardToolStripMenuItem.Image = global::MiniClient.Properties.Resources.vcard;
this.vcardToolStripMenuItem.Name = "vcardToolStripMenuItem";
this.vcardToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
this.vcardToolStripMenuItem.Text = "vcard";
this.vcardToolStripMenuItem.Click += new System.EventHandler(this.vcardToolStripMenuItem_Click);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Image = global::MiniClient.Properties.Resources.user_delete;
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
this.deleteToolStripMenuItem.Text = "delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// sendFileToolStripMenuItem
//
this.sendFileToolStripMenuItem.Image = global::MiniClient.Properties.Resources.package;
this.sendFileToolStripMenuItem.Name = "sendFileToolStripMenuItem";
this.sendFileToolStripMenuItem.Size = new System.Drawing.Size(128, 22);
this.sendFileToolStripMenuItem.Text = "Send File";
this.sendFileToolStripMenuItem.ToolTipText = "Send File to Buddy";
this.sendFileToolStripMenuItem.Click += new System.EventHandler(this.sendFileToolStripMenuItem_Click);
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(347, 24);
this.menuStrip1.TabIndex = 5;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.connectToolStripMenuItem,
this.disconnectToolStripMenuItem,
this.toolStripMenuItem1,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
this.fileToolStripMenuItem.Text = "File";
//
// connectToolStripMenuItem
//
this.connectToolStripMenuItem.Image = global::MiniClient.Properties.Resources.connect;
this.connectToolStripMenuItem.Name = "connectToolStripMenuItem";
this.connectToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
this.connectToolStripMenuItem.Text = "Connect";
this.connectToolStripMenuItem.Click += new System.EventHandler(this.connectToolStripMenuItem_Click);
//
// disconnectToolStripMenuItem
//
this.disconnectToolStripMenuItem.Image = global::MiniClient.Properties.Resources.disconnect;
this.disconnectToolStripMenuItem.Name = "disconnectToolStripMenuItem";
this.disconnectToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
this.disconnectToolStripMenuItem.Text = "Disconnect";
this.disconnectToolStripMenuItem.Click += new System.EventHandler(this.disconnectToolStripMenuItem_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(134, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Image = global::MiniClient.Properties.Resources.door_in;
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButtonAdd,
this.toolStripButtonSearch});
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(347, 25);
this.toolStrip1.TabIndex = 8;
this.toolStrip1.Text = "toolStrip1";
//
// toolStripButtonAdd
//
this.toolStripButtonAdd.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButtonAdd.Image = global::MiniClient.Properties.Resources.user_add;
this.toolStripButtonAdd.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonAdd.Name = "toolStripButtonAdd";
this.toolStripButtonAdd.Size = new System.Drawing.Size(23, 22);
this.toolStripButtonAdd.Text = "toolStripButton1";
this.toolStripButtonAdd.ToolTipText = "Add User";
this.toolStripButtonAdd.Click += new System.EventHandler(this.toolStripButtonAdd_Click);
//
// toolStripButtonSearch
//
this.toolStripButtonSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButtonSearch.Image = global::MiniClient.Properties.Resources.zoom;
this.toolStripButtonSearch.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonSearch.Name = "toolStripButtonSearch";
this.toolStripButtonSearch.Size = new System.Drawing.Size(23, 22);
this.toolStripButtonSearch.Text = "toolStripButton1";
this.toolStripButtonSearch.ToolTipText = "User Search";
this.toolStripButtonSearch.Click += new System.EventHandler(this.toolStripButtonSearch_Click);
//
// executeToolStripMenuItem
//
this.executeToolStripMenuItem.Name = "executeToolStripMenuItem";
this.executeToolStripMenuItem.Size = new System.Drawing.Size(32, 19);
//
// configureToolStripMenuItem
//
this.configureToolStripMenuItem.Name = "configureToolStripMenuItem";
this.configureToolStripMenuItem.Size = new System.Drawing.Size(32, 19);
//
// executeToolStripMenuItem1
//
this.executeToolStripMenuItem1.Name = "executeToolStripMenuItem1";
this.executeToolStripMenuItem1.Size = new System.Drawing.Size(32, 19);
//
// configureToolStripMenuItem1
//
this.configureToolStripMenuItem1.Name = "configureToolStripMenuItem1";
this.configureToolStripMenuItem1.Size = new System.Drawing.Size(32, 19);
//
// tabSocket
//
this.tabSocket.Controls.Add(this.rtfDebugSocket);
this.tabSocket.ImageIndex = 0;
this.tabSocket.Location = new System.Drawing.Point(4, 23);
this.tabSocket.Name = "tabSocket";
this.tabSocket.Size = new System.Drawing.Size(339, 362);
this.tabSocket.TabIndex = 2;
this.tabSocket.Text = "Socket Debug";
this.tabSocket.UseVisualStyleBackColor = true;
//
// rtfDebugSocket
//
this.rtfDebugSocket.BackColor = System.Drawing.SystemColors.Window;
this.rtfDebugSocket.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtfDebugSocket.Location = new System.Drawing.Point(0, 0);
this.rtfDebugSocket.Name = "rtfDebugSocket";
this.rtfDebugSocket.ReadOnly = true;
this.rtfDebugSocket.Size = new System.Drawing.Size(339, 362);
this.rtfDebugSocket.TabIndex = 1;
this.rtfDebugSocket.Text = "";
//
// tabDebug
//
this.tabDebug.Controls.Add(this.rtfDebug);
this.tabDebug.ImageIndex = 0;
this.tabDebug.Location = new System.Drawing.Point(4, 23);
this.tabDebug.Name = "tabDebug";
this.tabDebug.Size = new System.Drawing.Size(339, 362);
this.tabDebug.TabIndex = 1;
this.tabDebug.Text = "Debug";
this.tabDebug.UseVisualStyleBackColor = true;
this.tabDebug.Visible = false;
//
// rtfDebug
//
this.rtfDebug.BackColor = System.Drawing.SystemColors.Window;
this.rtfDebug.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtfDebug.Location = new System.Drawing.Point(0, 0);
this.rtfDebug.Name = "rtfDebug";
this.rtfDebug.ReadOnly = true;
this.rtfDebug.Size = new System.Drawing.Size(339, 362);
this.rtfDebug.TabIndex = 0;
this.rtfDebug.Text = "";
//
// tabGC
//
this.tabGC.Controls.Add(this.treeGC);
this.tabGC.Controls.Add(this.ToolStripGC);
this.tabGC.ImageIndex = 2;
this.tabGC.Location = new System.Drawing.Point(4, 23);
this.tabGC.Name = "tabGC";
this.tabGC.Padding = new System.Windows.Forms.Padding(3);
this.tabGC.Size = new System.Drawing.Size(339, 362);
this.tabGC.TabIndex = 3;
this.tabGC.Text = "GroupChat";
this.tabGC.UseVisualStyleBackColor = true;
//
// treeGC
//
this.treeGC.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeGC.ImageIndex = 0;
this.treeGC.ImageList = this.ils16;
this.treeGC.Location = new System.Drawing.Point(3, 28);
this.treeGC.Name = "treeGC";
this.treeGC.SelectedImageIndex = 0;
this.treeGC.Size = new System.Drawing.Size(333, 331);
this.treeGC.TabIndex = 20;
//
// ils16
//
this.ils16.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ils16.ImageStream")));
this.ils16.TransparentColor = System.Drawing.Color.Transparent;
this.ils16.Images.SetKeyName(0, "application_xp_terminal.png");
this.ils16.Images.SetKeyName(1, "folder_user.png");
this.ils16.Images.SetKeyName(2, "group.png");
this.ils16.Images.SetKeyName(3, "user.png");
this.ils16.Images.SetKeyName(4, "comments.png");
this.ils16.Images.SetKeyName(5, "server.png");
//
// ToolStripGC
//
this.ToolStripGC.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButtonFindRooms,
this.toolStripButtonFindPart});
this.ToolStripGC.Location = new System.Drawing.Point(3, 3);
this.ToolStripGC.Name = "ToolStripGC";
this.ToolStripGC.Size = new System.Drawing.Size(333, 25);
this.ToolStripGC.TabIndex = 19;
this.ToolStripGC.Text = "toolStrip2";
//
// toolStripButtonFindRooms
//
this.toolStripButtonFindRooms.Image = global::MiniClient.Properties.Resources.comments;
this.toolStripButtonFindRooms.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonFindRooms.Name = "toolStripButtonFindRooms";
this.toolStripButtonFindRooms.Size = new System.Drawing.Size(82, 22);
this.toolStripButtonFindRooms.Text = "Find Rooms";
this.toolStripButtonFindRooms.Click += new System.EventHandler(this.toolStripButtonFindRooms_Click);
//
// toolStripButtonFindPart
//
this.toolStripButtonFindPart.Image = global::MiniClient.Properties.Resources.group;
this.toolStripButtonFindPart.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonFindPart.Name = "toolStripButtonFindPart";
this.toolStripButtonFindPart.Size = new System.Drawing.Size(106, 22);
this.toolStripButtonFindPart.Text = "Find Participants";
this.toolStripButtonFindPart.Click += new System.EventHandler(this.toolStripButtonFindPart_Click);
//
// tabRoster
//
this.tabRoster.Controls.Add(this.rosterControl);
this.tabRoster.Controls.Add(this.cboStatus);
this.tabRoster.ImageIndex = 3;
this.tabRoster.Location = new System.Drawing.Point(4, 23);
this.tabRoster.Name = "tabRoster";
this.tabRoster.Size = new System.Drawing.Size(339, 362);
this.tabRoster.TabIndex = 0;
this.tabRoster.Text = "Roster";
this.tabRoster.UseVisualStyleBackColor = true;
//
// rosterControl
//
this.rosterControl.ColorGroup = System.Drawing.SystemColors.Highlight;
this.rosterControl.ColorResource = System.Drawing.SystemColors.ControlText;
this.rosterControl.ColorRoot = System.Drawing.SystemColors.Highlight;
this.rosterControl.ColorRoster = System.Drawing.SystemColors.ControlText;
this.rosterControl.DefaultGroupName = "ungrouped";
this.rosterControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.rosterControl.HideEmptyGroups = true;
this.rosterControl.Location = new System.Drawing.Point(0, 21);
this.rosterControl.Name = "rosterControl";
this.rosterControl.Size = new System.Drawing.Size(339, 341);
this.rosterControl.TabIndex = 13;
this.rosterControl.SelectionChanged += new System.EventHandler(this.rosterControl_SelectionChanged);
//
// cboStatus
//
this.cboStatus.Dock = System.Windows.Forms.DockStyle.Top;
this.cboStatus.Location = new System.Drawing.Point(0, 0);
this.cboStatus.Name = "cboStatus";
this.cboStatus.Size = new System.Drawing.Size(339, 21);
this.cboStatus.TabIndex = 10;
this.cboStatus.SelectedValueChanged += new System.EventHandler(this.cboStatus_SelectedValueChanged);
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabRoster);
this.tabControl1.Controls.Add(this.tabGC);
this.tabControl1.Controls.Add(this.tabDebug);
this.tabControl1.Controls.Add(this.tabSocket);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.ImageList = this.ils16;
this.tabControl1.Location = new System.Drawing.Point(0, 49);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(347, 389);
this.tabControl1.TabIndex = 9;
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(347, 462);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.statusBar1);
this.Name = "frmMain";
this.Text = "Mini Client";
this.contextMenuGC.ResumeLayout(false);
this.contextMenuStripRoster.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.tabSocket.ResumeLayout(false);
this.tabDebug.ResumeLayout(false);
this.tabGC.ResumeLayout(false);
this.tabGC.PerformLayout();
this.ToolStripGC.ResumeLayout(false);
this.ToolStripGC.PerformLayout();
this.tabRoster.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new frmMain());
}
#region << XmppConnection events >>
private void XmppCon_OnReadXml(object sender, string xml)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new XmlHandler(XmppCon_OnReadXml), new object[]{sender, xml});
return;
}
rtfDebug.SelectionStart = rtfDebug.Text.Length;
rtfDebug.SelectionLength = 0;
rtfDebug.SelectionColor = Color.Red;
rtfDebug.AppendText("RECV: ");
rtfDebug.SelectionColor = Color.Black;
rtfDebug.AppendText(xml);
rtfDebug.AppendText("\r\n");
}
private void XmppCon_OnWriteXml(object sender, string xml)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new XmlHandler(XmppCon_OnWriteXml), new object[]{sender, xml});
return;
}
rtfDebug.SelectionStart = rtfDebug.Text.Length;
rtfDebug.SelectionLength = 0;
rtfDebug.SelectionColor = Color.Blue;
rtfDebug.AppendText("SEND: ");
rtfDebug.SelectionColor = Color.Black;
rtfDebug.AppendText(xml);
rtfDebug.AppendText("\r\n");
}
private void XmppCon_OnRosterStart(object sender)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new ObjectHandler(XmppCon_OnRosterStart), new object[]{this});
return;
}
// Disable redraw for faster updating
rosterControl.BeginUpdate();
}
private void XmppCon_OnRosterEnd(object sender)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new ObjectHandler(XmppCon_OnRosterEnd), new object[]{this});
return;
}
// enable redraw again
rosterControl.EndUpdate();
rosterControl.ExpandAll();
//// Send our Online Presence now, this is done in the cboStatus SelectionChanges event
//// after the next line
//cboStatus.SelectedIndex = 5;
// since 0.97 we don't need this anymore ==> AutoPresence property
}
private void XmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new agsXMPP.XmppClientConnection.RosterHandler(XmppCon_OnRosterItem), new object[]{this, item});
return;
}
if (item.Subscription != SubscriptionType.remove)
{
rosterControl.AddRosterItem(item);
}
else
{
rosterControl.RemoveRosterItem(item);
}
}
private void XmppCon_OnAgentStart(object sender)
{
}
private void XmppCon_OnAgentEnd(object sender)
{
}
private void XmppCon_OnAgentItem(object sender, agsXMPP.protocol.iq.agent.Agent agent)
{
}
private void XmppCon_OnLogin(object sender)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new ObjectHandler(XmppCon_OnLogin), new object[] { sender});
return;
}
connectToolStripMenuItem.Enabled = false;
disconnectToolStripMenuItem.Enabled = true;
statusBar1.Text = "Online";
DiscoServer();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void XmppCon_OnAuthError(object sender, Element e)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new XmppElementHandler(XmppCon_OnAuthError), new object[]{sender, e});
return;
}
if (XmppCon.XmppConnectionState != XmppConnectionState.Disconnected)
XmppCon.Close();
MessageBox.Show("Authentication Error!\r\nWrong password or username.",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="pres"></param>
private void XmppCon_OnPresence(object sender, Presence pres)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new OnPresenceDelegate(XmppCon_OnPresence), new object[]{sender, pres});
return;
}
if (pres.Type == PresenceType.subscribe)
{
frmSubscribe f = new frmSubscribe(XmppCon, pres.From);
f.Show();
}
else if(pres.Type == PresenceType.subscribed)
{
}
else if(pres.Type == PresenceType.unsubscribe)
{
}
else if(pres.Type == PresenceType.unsubscribed)
{
}
else
{
try
{
rosterControl.SetPresence(pres);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
private void XmppCon_OnIq(object sender, agsXMPP.protocol.client.IQ iq)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new IqHandler(XmppCon_OnIq), new object[] { sender, iq });
return;
}
if (iq != null)
{
// No Iq with query
if (iq.HasTag(typeof(agsXMPP.protocol.extensions.si.SI)))
{
if (iq.Type == IqType.set)
{
agsXMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI;
agsXMPP.protocol.extensions.filetransfer.File file = si.File;
if (file != null)
{
// somebody wants to send a file to us
Console.WriteLine(file.Size.ToString());
Console.WriteLine(file.Name);
frmFileTransfer frmFile = new frmFileTransfer(XmppCon, iq);
frmFile.Show();
}
}
}
else
{
Element query = iq.Query;
if (query != null)
{
if (query.GetType() == typeof(agsXMPP.protocol.iq.version.Version))
{
// its a version IQ VersionIQ
agsXMPP.protocol.iq.version.Version version = query as agsXMPP.protocol.iq.version.Version;
if (iq.Type == IqType.get)
{
// Somebody wants to know our client version, so send it back
iq.SwitchDirection();
iq.Type = IqType.result;
version.Name = "MiniClient";
version.Ver = "0.5";
version.Os = Environment.OSVersion.ToString();
XmppCon.Send(iq);
}
}
}
}
}
}
/// <summary>
/// We received a message
/// </summary>
/// <param name="sender"></param>
/// <param name="msg"></param>
private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new OnMessageDelegate(XmppCon_OnMessage), new object[] { sender, msg });
return;
}
// Dont handle GroupChat Messages here, they have their own callbacks in the
// GroupChat Form
if (msg.Type == MessageType.groupchat)
return;
if (msg.Type == MessageType.error)
{
//Handle errors here
// we dont handle them in this example
return;
}
// check for xData Message
if (msg.HasTag(typeof(Data)))
{
Element e = msg.SelectSingleElement(typeof(Data));
Data xdata = e as Data;
if (xdata.Type == XDataFormType.form)
{
frmXData fXData = new frmXData(xdata);
fXData.Text = "xData Form from " + msg.From.ToString();
fXData.Show();
}
}
else if(msg.HasTag(typeof(agsXMPP.protocol.extensions.ibb.Data)))
{
// ignore IBB messages
return;
}
else
{
if (msg.Body != null)
{
if (!Util.ChatForms.ContainsKey(msg.From.Bare))
{
RosterNode rn = rosterControl.GetRosterItem(msg.From);
string nick = msg.From.Bare;
if (rn != null)
nick = rn.Text;
frmChat f = new frmChat(msg.From, XmppCon, nick);
f.Show();
f.IncomingMessage(msg);
}
}
}
}
private void XmppCon_OnClose(object sender)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new ObjectHandler(XmppCon_OnClose), new object[] {sender});
return;
}
Console.WriteLine("OnClose");
connectToolStripMenuItem.Enabled = true;
disconnectToolStripMenuItem.Enabled = false;
cboStatus.Text = "offline";
statusBar1.Text = "OffLine";
rosterControl.Clear();
}
private void XmppCon_OnError(object sender, Exception ex)
{
}
#endregion
private bool ClientSocket_OnValidateCertificate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}
private void ClientSocket_OnReceive(object sender, byte[] data, int count)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new agsXMPP.net.ClientSocket.OnSocketDataHandler(ClientSocket_OnReceive), new object[]{sender, data, count});
return;
}
try
{
rtfDebugSocket.SelectionStart = rtfDebug.Text.Length;
rtfDebugSocket.SelectionLength = 0;
rtfDebugSocket.SelectionColor = Color.Red;
rtfDebugSocket.AppendText("RECV: ");
rtfDebugSocket.SelectionStart = rtfDebug.Text.Length;
rtfDebugSocket.SelectionLength = 0;
rtfDebugSocket.SelectionColor = Color.Black;
rtfDebugSocket.AppendText(System.Text.Encoding.Default.GetString(data, 0, count));
rtfDebugSocket.AppendText("\r\n\r\n");
}
catch { }
}
private void ClientSocket_OnSend(object sender, byte[] data, int count)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new agsXMPP.net.ClientSocket.OnSocketDataHandler(ClientSocket_OnSend), new object[]{sender, data, count});
return;
}
try
{
rtfDebugSocket.SelectionStart = rtfDebug.Text.Length;
rtfDebugSocket.SelectionLength = 0;
rtfDebugSocket.SelectionColor = Color.Blue;
rtfDebugSocket.AppendText("SEND: ");
rtfDebugSocket.SelectionStart = rtfDebug.Text.Length;
rtfDebugSocket.SelectionLength = 0;
rtfDebugSocket.SelectionColor = Color.Black;
rtfDebugSocket.AppendText(System.Text.Encoding.Default.GetString(data, 0, count));
rtfDebugSocket.AppendText("\r\n\r\n");
}
catch { }
}
private void XmppCon_OnXmppConnectionStateChanged(object sender, XmppConnectionState state)
{
Console.WriteLine("OnXmppConnectionStateChanged: " + state.ToString());
}
private void OnBrowseIQ(object sender, IQ iq, object data)
{
Element s = iq.SelectSingleElement(typeof(agsXMPP.protocol.iq.browse.Service));
if (s!=null)
{
agsXMPP.protocol.iq.browse.Service service = s as agsXMPP.protocol.iq.browse.Service;
string[] ns = service.GetNamespaces();
}
}
#region << RequestDiscover >>
public void RequestDiscovery()
{
//DiscoItemsIq discoIq = new DiscoItemsIq(IqType.get);
////TreeNode node = treeGC.SelectedNode;
////discoIq.To = new Jid(this.XmppCon.Server);
//discoIq.To = new Jid("amessage.info");
//this.XmppCon.IqGrabber.SendIq(discoIq, new IqCB(OnGetDiscovery), null);
}
/// <summary>
/// Callback
/// </summary>
/// <param name="sender"></param>
/// <param name="iq"></param>
/// <param name="data"></param>
private void OnGetDiscovery(object sender, IQ iq, object data)
{
DiscoItems items = iq.Query as DiscoItems;
if (items == null)
return;
DiscoItem[] rooms = items.GetDiscoItems();
foreach (DiscoItem item in rooms)
{
Console.WriteLine(item.Name);
}
}
#endregion
#region << lookup chatrooms on a chatserver using service discovery >>
/// <summary>
/// Discover chatromms of a chat server using disco (service discovery)
/// </summary>
private void FindChatRooms()
{
TreeNode node = treeGC.SelectedNode;
if (node == null || node.Level != 0)
return;
DiscoItemsIq discoIq = new DiscoItemsIq(IqType.get);
discoIq.To = new Jid(node.Text);
this.XmppCon.IqGrabber.SendIq(discoIq, new IqCB(OnGetChatRooms), node);
}
/// <summary>
/// Callback
/// </summary>
/// <param name="sender"></param>
/// <param name="iq"></param>
/// <param name="data"></param>
private void OnGetChatRooms(object sender, IQ iq, object data)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new IqCB(OnGetChatRooms), new object[] { sender, iq, data });
return;
}
TreeNode node = data as TreeNode;
node.Nodes.Clear();
DiscoItems items = iq.Query as DiscoItems;
if (items == null)
return;
DiscoItem[] rooms = items.GetDiscoItems();
foreach (DiscoItem item in rooms)
{
TreeNode n = new TreeNode(item.Name);
n.Tag = item.Jid.ToString();
n.ImageIndex = n.SelectedImageIndex = IMAGE_CHATROOM;
node.Nodes.Add(n);
}
}
private void FindParticipants()
{
TreeNode node = treeGC.SelectedNode;
if (node == null && node.Level != 1)
return;
DiscoItemsIq discoIq = new DiscoItemsIq(IqType.get);
discoIq.To = new Jid((string) node.Tag);
this.XmppCon.IqGrabber.SendIq(discoIq, new IqCB(OnGetParticipants), node);
}
private void OnGetParticipants(object sender, IQ iq, object data)
{
if (InvokeRequired)
{
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new IqCB(OnGetParticipants), new object[] { sender, iq, data });
return;
}
TreeNode node = data as TreeNode;
node.Nodes.Clear();
DiscoItems items = iq.Query as DiscoItems;
if (items == null)
return;
DiscoItem[] rooms = items.GetDiscoItems();
foreach (DiscoItem item in rooms)
{
TreeNode n = new TreeNode(item.Jid.Resource);
n.Tag = item.Jid.ToString();
n.ImageIndex = n.SelectedImageIndex = IMAGE_PARTICIPANT;
node.Nodes.Add(n);
}
}
#endregion
private void chatToolStripMenuItem_Click(object sender, EventArgs e)
{
RosterNode node = rosterControl.SelectedItem();
if (node != null)
{
if (!Util.ChatForms.ContainsKey(node.RosterItem.Jid.ToString()))
{
frmChat f = new frmChat(node.RosterItem.Jid, XmppCon, node.Text);
f.Show();
}
}
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
RosterNode node = rosterControl.SelectedItem();
if (node != null)
{
RosterIq riq = new RosterIq();
riq.Type = IqType.set;
XmppCon.RosterManager.RemoveRosterItem(node.RosterItem.Jid);
}
}
private void sendFileToolStripMenuItem_Click(object sender, EventArgs e)
{
RosterNode node = rosterControl.SelectedItem();
if (node != null)
{
if (node.Nodes.Count > 0)
{
Jid jid = node.RosterItem.Jid;
jid.Resource = node.FirstNode.Text;
frmFileTransfer ft = new frmFileTransfer(XmppCon, jid);
ft.Show();
}
}
}
private void vcardToolStripMenuItem_Click(object sender, EventArgs e)
{
RosterNode node = rosterControl.SelectedItem();
if (node != null)
{
frmVcard f = new frmVcard(node.RosterItem.Jid, XmppCon);
f.Show();
}
}
private void rosterControl_SelectionChanged(object sender, EventArgs e)
{
RosterNode node = rosterControl.SelectedItem();
if (node != null)
{
if (node.NodeType == RosterNodeType.RosterNode)
rosterControl.ContextMenuStrip = this.contextMenuStripRoster;
else if (node.NodeType == RosterNodeType.GroupNode)
rosterControl.ContextMenuStrip = null; // Add Group context menu here
else if (node.NodeType == RosterNodeType.RootNode)
rosterControl.ContextMenuStrip = null; // Add RootNode context menu here
else if (node.NodeType == RosterNodeType.ResourceNode)
rosterControl.ContextMenuStrip = null; // Add Resource Context Menu here
}
}
private void connectToolStripMenuItem_Click(object sender, EventArgs e)
{
frmLogin f = new frmLogin(XmppCon);
if (f.ShowDialog() == DialogResult.OK)
{
XmppCon.Open();
// for compression debug statistics
// XmppCon.ClientSocket.OnIncomingCompressionDebug += new agsXMPP.net.BaseSocket.OnSocketCompressionDebugHandler(ClientSocket_OnIncomingCompressionDebug);
// XmppCon.ClientSocket.OnOutgoingCompressionDebug += new agsXMPP.net.BaseSocket.OnSocketCompressionDebugHandler(ClientSocket_OnOutgoingCompressionDebug);
}
}
private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
{
XmppCon.Close();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void toolStripButtonAdd_Click(object sender, EventArgs e)
{
frmAddRoster f = new frmAddRoster(XmppCon);
f.Show();
}
private void cboStatus_SelectedValueChanged(object sender, EventArgs e)
{
if (XmppCon != null && XmppCon.Authenticated)
{
if (cboStatus.Text == "online")
{
XmppCon.Show = ShowType.NONE;
}
else if (cboStatus.Text == "offline")
{
XmppCon.Close();
}
else
{
XmppCon.Show = (ShowType)Enum.Parse(typeof(ShowType), cboStatus.Text);
}
XmppCon.SendMyPresence();
}
}
private void joinToolStripMenuItem_Click(object sender, EventArgs e)
{
// Join a ChatRoom
if (XmppCon.XmppConnectionState == XmppConnectionState.Disconnected)
return;
TreeNode node = this.treeGC.SelectedNode;
if (node != null && node.Level == 1)
{
// Ask for the Nickname for this GroupChat
frmInputBox input = new frmInputBox("Enter your Nickname for the chatroom", "Nickname", "Nickname");
if (input.ShowDialog() == DialogResult.OK)
{
Jid jid = new Jid((string)node.Tag);
string nickname = input.Result;
frmGroupChat gc = new frmGroupChat(this.XmppCon, jid, nickname);
gc.Show();
}
}
}
private void toolStripButtonFindRooms_Click(object sender, EventArgs e)
{
if (XmppCon.XmppConnectionState == XmppConnectionState.Disconnected)
return;
FindChatRooms();
}
private void toolStripButtonFindPart_Click(object sender, EventArgs e)
{
if (XmppCon.XmppConnectionState == XmppConnectionState.Disconnected)
return;
FindParticipants();
}
#region << Disco Server >>
// Sending Disco request to the server we are connected to for discovering
// the services runing on our server
private void DiscoServer()
{
DiscoManager dm = new DiscoManager(XmppCon);
dm.DiscoverItems(new Jid(XmppCon.Server), new IqCB(OnDiscoServerResult), null);
}
/// <summary>
/// Callback
/// </summary>
/// <param name="sender"></param>
/// <param name="iq"></param>
/// <param name="data"></param>
private void OnDiscoServerResult(object sender, IQ iq, object data)
{
if (iq.Type == IqType.result)
{
Element query = iq.Query;
if (query != null && query.GetType() == typeof(DiscoItems))
{
DiscoItems items = query as DiscoItems;
DiscoItem[] itms = items.GetDiscoItems();
DiscoManager dm = new DiscoManager(XmppCon);
foreach (DiscoItem itm in itms)
{
if (itm.Jid != null)
dm.DiscoverInformation(itm.Jid, new IqCB(OnDiscoInfoResult), itm);
}
}
}
}
private void OnDiscoInfoResult(object sender, IQ iq, object data)
{
// <iq from='proxy.cachet.myjabber.net' to='[email protected]/Exodus' type='result' id='jcl_19'>
// <query xmlns='http://jabber.org/protocol/disco#info'>
// <identity category='proxy' name='SOCKS5 Bytestreams Service' type='bytestreams'/>
// <feature var='http://jabber.org/protocol/bytestreams'/>
// <feature var='http://jabber.org/protocol/disco#info'/>
// </query>
// </iq>
if (iq.Type == IqType.result)
{
if (iq.Query is DiscoInfo)
{
DiscoInfo di = iq.Query as DiscoInfo;
if (di.HasFeature(agsXMPP.Uri.IQ_SEARCH))
{
Jid jid = iq.From;
if (!Util.Services.Search.Contains(jid))
Util.Services.Search.Add(jid);
}
else if (di.HasFeature(agsXMPP.Uri.BYTESTREAMS))
{
Jid jid = iq.From;
if (!Util.Services.Proxy.Contains(jid))
Util.Services.Proxy.Add(jid);
}
}
}
}
#endregion
private void toolStripButtonSearch_Click(object sender, EventArgs e)
{
frmSearch fSearch = new frmSearch(this.XmppCon);
fSearch.Show();
}
}
}
|
octgn/Agsxmpp
|
trunk/samples/VS2005/MiniClient/frmMain.cs
|
C#
|
gpl-2.0
| 57,737 |
/*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 1999 Lars Knoll ([email protected])
* (C) 1999 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
* Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#pragma once
#include "HTMLFormControlElementWithState.h"
#include "TypeAhead.h"
namespace WebCore {
class HTMLOptionsCollection;
class HTMLSelectElement : public HTMLFormControlElementWithState, private TypeAheadDataSource {
public:
static Ref<HTMLSelectElement> create(const QualifiedName&, Document&, HTMLFormElement*);
WEBCORE_EXPORT int selectedIndex() const;
WEBCORE_EXPORT void setSelectedIndex(int);
WEBCORE_EXPORT void optionSelectedByUser(int index, bool dispatchChangeEvent, bool allowMultipleSelection = false);
String validationMessage() const final;
bool valueMissing() const final;
WEBCORE_EXPORT unsigned length() const;
unsigned size() const { return m_size; }
bool multiple() const { return m_multiple; }
bool usesMenuList() const;
using OptionOrOptGroupElement = Variant<RefPtr<HTMLOptionElement>, RefPtr<HTMLOptGroupElement>>;
using HTMLElementOrInt = Variant<RefPtr<HTMLElement>, int>;
WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, const std::optional<HTMLElementOrInt>& before);
using Node::remove;
ExceptionOr<void> remove(HTMLOptionElement&);
WEBCORE_EXPORT void remove(int);
WEBCORE_EXPORT String value() const;
WEBCORE_EXPORT void setValue(const String&);
WEBCORE_EXPORT Ref<HTMLOptionsCollection> options();
Ref<HTMLCollection> selectedOptions();
void optionElementChildrenChanged();
void setRecalcListItems();
void invalidateSelectedItems();
void updateListItemSelectedStates();
WEBCORE_EXPORT const Vector<HTMLElement*>& listItems() const;
void accessKeyAction(bool sendMouseEvents) final;
void accessKeySetSelectedIndex(int);
WEBCORE_EXPORT void setMultiple(bool);
WEBCORE_EXPORT void setSize(unsigned);
// Called by the bindings for the unnamed index-setter.
ExceptionOr<void> setItem(unsigned index, HTMLOptionElement*);
ExceptionOr<void> setLength(unsigned);
WEBCORE_EXPORT HTMLOptionElement* namedItem(const AtomicString& name);
WEBCORE_EXPORT HTMLOptionElement* item(unsigned index);
void scrollToSelection();
void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true);
bool canSelectAll() const;
void selectAll();
int listToOptionIndex(int listIndex) const;
void listBoxOnChange();
int optionToListIndex(int optionIndex) const;
int activeSelectionStartListIndex() const;
int activeSelectionEndListIndex() const;
void setActiveSelectionAnchorIndex(int);
void setActiveSelectionEndIndex(int);
void updateListBoxSelection(bool deselectOtherOptions);
// For use in the implementation of HTMLOptionElement.
void optionSelectionStateChanged(HTMLOptionElement&, bool optionIsSelected);
bool allowsNonContiguousSelection() const { return m_allowsNonContiguousSelection; };
protected:
HTMLSelectElement(const QualifiedName&, Document&, HTMLFormElement*);
private:
const AtomicString& formControlType() const final;
bool isKeyboardFocusable(KeyboardEvent&) const final;
bool isMouseFocusable() const final;
void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection) final;
void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) final;
bool canStartSelection() const final { return false; }
bool isEnumeratable() const final { return true; }
bool supportLabels() const final { return true; }
FormControlState saveFormControlState() const final;
void restoreFormControlState(const FormControlState&) final;
void parseAttribute(const QualifiedName&, const AtomicString&) final;
bool isPresentationAttribute(const QualifiedName&) const final;
bool childShouldCreateRenderer(const Node&) const final;
RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
bool appendFormData(FormDataList&, bool) final;
void reset() final;
void defaultEventHandler(Event&) final;
bool willRespondToMouseClickEvents() final;
void dispatchChangeEventForMenuList();
void didRecalcStyle(Style::Change) final;
void recalcListItems(bool updateSelectedStates = true) const;
void deselectItems(HTMLOptionElement* excludeElement = nullptr);
void typeAheadFind(KeyboardEvent&);
void saveLastSelection();
InsertionNotificationRequest insertedInto(ContainerNode&) final;
bool isOptionalFormControl() const final { return !isRequiredFormControl(); }
bool isRequiredFormControl() const final;
bool hasPlaceholderLabelOption() const;
enum SelectOptionFlag {
DeselectOtherOptions = 1 << 0,
DispatchChangeEvent = 1 << 1,
UserDriven = 1 << 2,
};
typedef unsigned SelectOptionFlags;
void selectOption(int optionIndex, SelectOptionFlags = 0);
void deselectItemsWithoutValidation(HTMLElement* elementToExclude = nullptr);
void parseMultipleAttribute(const AtomicString&);
int lastSelectedListIndex() const;
void updateSelectedState(int listIndex, bool multi, bool shift);
void menuListDefaultEventHandler(Event&);
bool platformHandleKeydownEvent(KeyboardEvent*);
void listBoxDefaultEventHandler(Event&);
void setOptionsChangedOnRenderer();
size_t searchOptionsForValue(const String&, size_t listIndexStart, size_t listIndexEnd) const;
enum SkipDirection { SkipBackwards = -1, SkipForwards = 1 };
int nextValidIndex(int listIndex, SkipDirection, int skip) const;
int nextSelectableListIndex(int startIndex) const;
int previousSelectableListIndex(int startIndex) const;
int firstSelectableListIndex() const;
int lastSelectableListIndex() const;
int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const;
void childrenChanged(const ChildChange&) final;
// TypeAheadDataSource functions.
int indexOfSelectedOption() const final;
int optionCount() const final;
String optionAtIndex(int index) const final;
// m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHRElement objects.
mutable Vector<HTMLElement*> m_listItems;
Vector<bool> m_lastOnChangeSelection;
Vector<bool> m_cachedStateForActiveSelection;
TypeAhead m_typeAhead;
unsigned m_size;
int m_lastOnChangeIndex;
int m_activeSelectionAnchorIndex;
int m_activeSelectionEndIndex;
bool m_isProcessingUserDrivenChange;
bool m_multiple;
bool m_activeSelectionState;
bool m_allowsNonContiguousSelection;
mutable bool m_shouldRecalcListItems;
};
} // namespace
|
Debian/openjfx
|
modules/web/src/main/native/Source/WebCore/html/HTMLSelectElement.h
|
C
|
gpl-2.0
| 7,761 |
/*
* f_rndis.c -- RNDIS link function driver
*
* Copyright (C) 2003-2005,2008 David Brownell
* Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
* Copyright (C) 2008 Nokia Corporation
* Copyright (C) 2009 Samsung Electronics
* Author: Michal Nazarewicz ([email protected])
*
* 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.
*/
/* #define VERBOSE_DEBUG */
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/etherdevice.h>
#include <linux/atomic.h>
#include "u_ether.h"
#include "u_ether_configfs.h"
#include "u_rndis.h"
#include "rndis.h"
/*
* This function is an RNDIS Ethernet port -- a Microsoft protocol that's
* been promoted instead of the standard CDC Ethernet. The published RNDIS
* spec is ambiguous, incomplete, and needlessly complex. Variants such as
* ActiveSync have even worse status in terms of specification.
*
* In short: it's a protocol controlled by (and for) Microsoft, not for an
* Open ecosystem or markets. Linux supports it *only* because Microsoft
* doesn't support the CDC Ethernet standard.
*
* The RNDIS data transfer model is complex, with multiple Ethernet packets
* per USB message, and out of band data. The control model is built around
* what's essentially an "RNDIS RPC" protocol. It's all wrapped in a CDC ACM
* (modem, not Ethernet) veneer, with those ACM descriptors being entirely
* useless (they're ignored). RNDIS expects to be the only function in its
* configuration, so it's no real help if you need composite devices; and
* it expects to be the first configuration too.
*
* There is a single technical advantage of RNDIS over CDC Ethernet, if you
* discount the fluff that its RPC can be made to deliver: it doesn't need
* a NOP altsetting for the data interface. That lets it work on some of the
* "so smart it's stupid" hardware which takes over configuration changes
* from the software, and adds restrictions like "no altsettings".
*
* Unfortunately MSFT's RNDIS drivers are buggy. They hang or oops, and
* have all sorts of contrary-to-specification oddities that can prevent
* them from working sanely. Since bugfixes (or accurate specs, letting
* Linux work around those bugs) are unlikely to ever come from MSFT, you
* may want to avoid using RNDIS on purely operational grounds.
*
* Omissions from the RNDIS 1.0 specification include:
*
* - Power management ... references data that's scattered around lots
* of other documentation, which is incorrect/incomplete there too.
*
* - There are various undocumented protocol requirements, like the need
* to send garbage in some control-OUT messages.
*
* - MS-Windows drivers sometimes emit undocumented requests.
*/
static unsigned int rndis_dl_max_pkt_per_xfer = 8;
module_param(rndis_dl_max_pkt_per_xfer, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(rndis_dl_max_pkt_per_xfer,
"Maximum packets per transfer for DL aggregation");
static unsigned int rndis_ul_max_pkt_per_xfer = 8;
module_param(rndis_ul_max_pkt_per_xfer, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(rndis_ul_max_pkt_per_xfer,
"Maximum packets per transfer for UL aggregation");
struct f_rndis {
struct gether port;
u8 ctrl_id, data_id;
u8 ethaddr[ETH_ALEN];
u32 vendorID;
const char *manufacturer;
int config;
struct usb_ep *notify;
struct usb_request *notify_req;
atomic_t notify_count;
};
static inline struct f_rndis *func_to_rndis(struct usb_function *f)
{
return container_of(f, struct f_rndis, port.func);
}
/* peak (theoretical) bulk transfer rate in bits-per-second */
static unsigned int bitrate(struct usb_gadget *g)
{
if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
return 13 * 1024 * 8 * 1000 * 8;
else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
return 13 * 512 * 8 * 1000 * 8;
else
return 19 * 64 * 1 * 1000 * 8;
}
/*-------------------------------------------------------------------------*/
/*
*/
#define RNDIS_STATUS_INTERVAL_MS 32
#define STATUS_BYTECOUNT 8 /* 8 bytes data */
/* interface descriptor: */
static struct usb_interface_descriptor rndis_control_intf = {
.bLength = sizeof rndis_control_intf,
.bDescriptorType = USB_DT_INTERFACE,
/* .bInterfaceNumber = DYNAMIC */
/* status endpoint is optional; this could be patched later */
.bNumEndpoints = 1,
.bInterfaceClass = USB_CLASS_COMM,
.bInterfaceSubClass = USB_CDC_SUBCLASS_ACM,
.bInterfaceProtocol = USB_CDC_ACM_PROTO_VENDOR,
/* .iInterface = DYNAMIC */
};
static struct usb_cdc_header_desc header_desc = {
.bLength = sizeof header_desc,
.bDescriptorType = USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_HEADER_TYPE,
.bcdCDC = cpu_to_le16(0x0110),
};
static struct usb_cdc_call_mgmt_descriptor call_mgmt_descriptor = {
.bLength = sizeof call_mgmt_descriptor,
.bDescriptorType = USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_CALL_MANAGEMENT_TYPE,
.bmCapabilities = 0x00,
.bDataInterface = 0x01,
};
static struct usb_cdc_acm_descriptor rndis_acm_descriptor = {
.bLength = sizeof rndis_acm_descriptor,
.bDescriptorType = USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_ACM_TYPE,
.bmCapabilities = 0x00,
};
static struct usb_cdc_union_desc rndis_union_desc = {
.bLength = sizeof(rndis_union_desc),
.bDescriptorType = USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_UNION_TYPE,
/* .bMasterInterface0 = DYNAMIC */
/* .bSlaveInterface0 = DYNAMIC */
};
/* the data interface has two bulk endpoints */
static struct usb_interface_descriptor rndis_data_intf = {
.bLength = sizeof rndis_data_intf,
.bDescriptorType = USB_DT_INTERFACE,
/* .bInterfaceNumber = DYNAMIC */
.bNumEndpoints = 2,
.bInterfaceClass = USB_CLASS_CDC_DATA,
.bInterfaceSubClass = 0,
.bInterfaceProtocol = 0,
/* .iInterface = DYNAMIC */
};
static struct usb_interface_assoc_descriptor
rndis_iad_descriptor = {
.bLength = sizeof rndis_iad_descriptor,
.bDescriptorType = USB_DT_INTERFACE_ASSOCIATION,
.bFirstInterface = 0, /* XXX, hardcoded */
.bInterfaceCount = 2, // control + data
.bFunctionClass = USB_CLASS_COMM,
.bFunctionSubClass = USB_CDC_SUBCLASS_ETHERNET,
.bFunctionProtocol = USB_CDC_PROTO_NONE,
/* .iFunction = DYNAMIC */
};
/* full speed support: */
static struct usb_endpoint_descriptor fs_notify_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_INT,
.wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
.bInterval = RNDIS_STATUS_INTERVAL_MS,
};
static struct usb_endpoint_descriptor fs_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
};
static struct usb_endpoint_descriptor fs_out_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
};
static struct usb_descriptor_header *eth_fs_function[] = {
(struct usb_descriptor_header *) &rndis_iad_descriptor,
/* control interface matches ACM, not Ethernet */
(struct usb_descriptor_header *) &rndis_control_intf,
(struct usb_descriptor_header *) &header_desc,
(struct usb_descriptor_header *) &call_mgmt_descriptor,
(struct usb_descriptor_header *) &rndis_acm_descriptor,
(struct usb_descriptor_header *) &rndis_union_desc,
(struct usb_descriptor_header *) &fs_notify_desc,
/* data interface has no altsetting */
(struct usb_descriptor_header *) &rndis_data_intf,
(struct usb_descriptor_header *) &fs_in_desc,
(struct usb_descriptor_header *) &fs_out_desc,
NULL,
};
/* high speed support: */
static struct usb_endpoint_descriptor hs_notify_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_INT,
.wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
.bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS)
};
static struct usb_endpoint_descriptor hs_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(512),
};
static struct usb_endpoint_descriptor hs_out_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(512),
};
static struct usb_descriptor_header *eth_hs_function[] = {
(struct usb_descriptor_header *) &rndis_iad_descriptor,
/* control interface matches ACM, not Ethernet */
(struct usb_descriptor_header *) &rndis_control_intf,
(struct usb_descriptor_header *) &header_desc,
(struct usb_descriptor_header *) &call_mgmt_descriptor,
(struct usb_descriptor_header *) &rndis_acm_descriptor,
(struct usb_descriptor_header *) &rndis_union_desc,
(struct usb_descriptor_header *) &hs_notify_desc,
/* data interface has no altsetting */
(struct usb_descriptor_header *) &rndis_data_intf,
(struct usb_descriptor_header *) &hs_in_desc,
(struct usb_descriptor_header *) &hs_out_desc,
NULL,
};
/* super speed support: */
static struct usb_endpoint_descriptor ss_notify_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_INT,
.wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
.bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS)
};
static struct usb_ss_ep_comp_descriptor ss_intr_comp_desc = {
.bLength = sizeof ss_intr_comp_desc,
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
/* the following 3 values can be tweaked if necessary */
/* .bMaxBurst = 0, */
/* .bmAttributes = 0, */
.wBytesPerInterval = cpu_to_le16(STATUS_BYTECOUNT),
};
static struct usb_endpoint_descriptor ss_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(1024),
};
static struct usb_endpoint_descriptor ss_out_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = cpu_to_le16(1024),
};
static struct usb_ss_ep_comp_descriptor ss_bulk_comp_desc = {
.bLength = sizeof ss_bulk_comp_desc,
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
/* the following 2 values can be tweaked if necessary */
/* .bMaxBurst = 0, */
/* .bmAttributes = 0, */
};
static struct usb_descriptor_header *eth_ss_function[] = {
(struct usb_descriptor_header *) &rndis_iad_descriptor,
/* control interface matches ACM, not Ethernet */
(struct usb_descriptor_header *) &rndis_control_intf,
(struct usb_descriptor_header *) &header_desc,
(struct usb_descriptor_header *) &call_mgmt_descriptor,
(struct usb_descriptor_header *) &rndis_acm_descriptor,
(struct usb_descriptor_header *) &rndis_union_desc,
(struct usb_descriptor_header *) &ss_notify_desc,
(struct usb_descriptor_header *) &ss_intr_comp_desc,
/* data interface has no altsetting */
(struct usb_descriptor_header *) &rndis_data_intf,
(struct usb_descriptor_header *) &ss_in_desc,
(struct usb_descriptor_header *) &ss_bulk_comp_desc,
(struct usb_descriptor_header *) &ss_out_desc,
(struct usb_descriptor_header *) &ss_bulk_comp_desc,
NULL,
};
/* string descriptors: */
static struct usb_string rndis_string_defs[] = {
[0].s = "RNDIS Communications Control",
[1].s = "RNDIS Ethernet Data",
[2].s = "RNDIS",
{ } /* end of list */
};
static struct usb_gadget_strings rndis_string_table = {
.language = 0x0409, /* en-us */
.strings = rndis_string_defs,
};
static struct usb_gadget_strings *rndis_strings[] = {
&rndis_string_table,
NULL,
};
/*-------------------------------------------------------------------------*/
static struct sk_buff *rndis_add_header(struct gether *port,
struct sk_buff *skb)
{
struct sk_buff *skb2;
struct rndis_packet_msg_type *header = NULL;
struct f_rndis *rndis = func_to_rndis(&port->func);
if (rndis->port.multi_pkt_xfer) {
if (port->header) {
header = port->header;
memset(header, 0, sizeof(*header));
header->MessageType = cpu_to_le32(RNDIS_MSG_PACKET);
header->MessageLength = cpu_to_le32(skb->len +
sizeof(*header));
header->DataOffset = cpu_to_le32(36);
header->DataLength = cpu_to_le32(skb->len);
pr_debug("MessageLength:%d DataLength:%d\n",
header->MessageLength,
header->DataLength);
return skb;
} else {
pr_err("RNDIS header is NULL.\n");
return NULL;
}
} else {
skb2 = skb_realloc_headroom(skb,
sizeof(struct rndis_packet_msg_type));
if (skb2)
rndis_add_hdr(skb2);
dev_kfree_skb_any(skb);
return skb2;
}
}
static void rndis_response_available(void *_rndis)
{
struct f_rndis *rndis = _rndis;
struct usb_request *req = rndis->notify_req;
struct usb_composite_dev *cdev = rndis->port.func.config->cdev;
__le32 *data = req->buf;
int status;
if (atomic_inc_return(&rndis->notify_count) != 1)
return;
/* Send RNDIS RESPONSE_AVAILABLE notification; a
* USB_CDC_NOTIFY_RESPONSE_AVAILABLE "should" work too
*
* This is the only notification defined by RNDIS.
*/
data[0] = cpu_to_le32(1);
data[1] = cpu_to_le32(0);
status = usb_ep_queue(rndis->notify, req, GFP_ATOMIC);
if (status) {
atomic_dec(&rndis->notify_count);
DBG(cdev, "notify/0 --> %d\n", status);
}
}
static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req)
{
struct f_rndis *rndis = req->context;
struct usb_composite_dev *cdev;
int status = req->status;
if (!rndis->port.func.config || !rndis->port.func.config->cdev)
return;
else
cdev = rndis->port.func.config->cdev;
/* after TX:
* - USB_CDC_GET_ENCAPSULATED_RESPONSE (ep0/control)
* - RNDIS_RESPONSE_AVAILABLE (status/irq)
*/
switch (status) {
case -ECONNRESET:
case -ESHUTDOWN:
/* connection gone */
atomic_set(&rndis->notify_count, 0);
break;
default:
DBG(cdev, "RNDIS %s response error %d, %d/%d\n",
ep->name, status,
req->actual, req->length);
/* FALLTHROUGH */
case 0:
if (ep != rndis->notify)
break;
/* handle multiple pending RNDIS_RESPONSE_AVAILABLE
* notifications by resending until we're done
*/
if (atomic_dec_and_test(&rndis->notify_count))
break;
status = usb_ep_queue(rndis->notify, req, GFP_ATOMIC);
if (status) {
atomic_dec(&rndis->notify_count);
DBG(cdev, "notify/1 --> %d\n", status);
}
break;
}
}
static void rndis_command_complete(struct usb_ep *ep, struct usb_request *req)
{
struct f_rndis *rndis = req->context;
int status;
rndis_init_msg_type *buf;
/* received RNDIS command from USB_CDC_SEND_ENCAPSULATED_COMMAND */
// spin_lock(&dev->lock);
status = rndis_msg_parser(rndis->config, (u8 *) req->buf);
if (status < 0)
pr_err("RNDIS command error %d, %d/%d\n",
status, req->actual, req->length);
buf = (rndis_init_msg_type *)req->buf;
if (buf->MessageType == RNDIS_MSG_INIT) {
if (buf->MaxTransferSize > 2048)
rndis->port.multi_pkt_xfer = true;
else
rndis->port.multi_pkt_xfer = false;
pr_debug("%s: MaxTransferSize: %d : multi_pkt_xfer: %s\n",
__func__, buf->MaxTransferSize,
rndis->port.multi_pkt_xfer ? "enabled" : "disabled");
if (rndis_dl_max_pkt_per_xfer <= 1)
rndis->port.multi_pkt_xfer = false;
}
// spin_unlock(&dev->lock);
}
static int
rndis_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
{
struct f_rndis *rndis = func_to_rndis(f);
struct usb_composite_dev *cdev = f->config->cdev;
struct usb_request *req = cdev->req;
int value = -EOPNOTSUPP;
u16 w_index = le16_to_cpu(ctrl->wIndex);
u16 w_value = le16_to_cpu(ctrl->wValue);
u16 w_length = le16_to_cpu(ctrl->wLength);
/* composite driver infrastructure handles everything except
* CDC class messages; interface activation uses set_alt().
*/
switch ((ctrl->bRequestType << 8) | ctrl->bRequest) {
/* RNDIS uses the CDC command encapsulation mechanism to implement
* an RPC scheme, with much getting/setting of attributes by OID.
*/
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
| USB_CDC_SEND_ENCAPSULATED_COMMAND:
if (w_value || w_index != rndis->ctrl_id)
goto invalid;
/* read the request; process it later */
value = w_length;
req->complete = rndis_command_complete;
req->context = rndis;
/* later, rndis_response_available() sends a notification */
break;
case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
| USB_CDC_GET_ENCAPSULATED_RESPONSE:
if (w_value || w_index != rndis->ctrl_id)
goto invalid;
else {
u8 *buf;
u32 n;
/* return the result */
buf = rndis_get_next_response(rndis->config, &n);
if (buf) {
memcpy(req->buf, buf, n);
req->complete = rndis_response_complete;
req->context = rndis;
rndis_free_response(rndis->config, buf);
value = n;
}
/* else stalls ... spec says to avoid that */
}
break;
default:
invalid:
VDBG(cdev, "invalid control req%02x.%02x v%04x i%04x l%d\n",
ctrl->bRequestType, ctrl->bRequest,
w_value, w_index, w_length);
}
/* respond with data transfer or status phase? */
if (value >= 0) {
DBG(cdev, "rndis req%02x.%02x v%04x i%04x l%d\n",
ctrl->bRequestType, ctrl->bRequest,
w_value, w_index, w_length);
req->zero = (value < w_length);
req->length = value;
value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
if (value < 0)
ERROR(cdev, "rndis response on err %d\n", value);
}
/* device either stalls (value < 0) or reports success */
return value;
}
static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
{
struct f_rndis *rndis = func_to_rndis(f);
struct usb_composite_dev *cdev = f->config->cdev;
/* we know alt == 0 */
if (intf == rndis->ctrl_id) {
if (rndis->notify->driver_data) {
VDBG(cdev, "reset rndis control %d\n", intf);
usb_ep_disable(rndis->notify);
}
if (!rndis->notify->desc) {
VDBG(cdev, "init rndis ctrl %d\n", intf);
if (config_ep_by_speed(cdev->gadget, f, rndis->notify))
goto fail;
}
usb_ep_enable(rndis->notify);
rndis->notify->driver_data = rndis;
} else if (intf == rndis->data_id) {
struct net_device *net;
if (rndis->port.in_ep->driver_data) {
DBG(cdev, "reset rndis\n");
gether_disconnect(&rndis->port);
}
if (!rndis->port.in_ep->desc || !rndis->port.out_ep->desc) {
DBG(cdev, "init rndis\n");
if (config_ep_by_speed(cdev->gadget, f,
rndis->port.in_ep) ||
config_ep_by_speed(cdev->gadget, f,
rndis->port.out_ep)) {
rndis->port.in_ep->desc = NULL;
rndis->port.out_ep->desc = NULL;
goto fail;
}
}
/* Avoid ZLPs; they can be troublesome. */
rndis->port.is_zlp_ok = false;
/* RNDIS should be in the "RNDIS uninitialized" state,
* either never activated or after rndis_uninit().
*
* We don't want data to flow here until a nonzero packet
* filter is set, at which point it enters "RNDIS data
* initialized" state ... but we do want the endpoints
* to be activated. It's a strange little state.
*
* REVISIT the RNDIS gadget code has done this wrong for a
* very long time. We need another call to the link layer
* code -- gether_updown(...bool) maybe -- to do it right.
*/
rndis->port.cdc_filter = 0;
DBG(cdev, "RNDIS RX/TX early activation ... \n");
net = gether_connect(&rndis->port);
if (IS_ERR(net))
return PTR_ERR(net);
rndis_set_param_dev(rndis->config, net,
&rndis->port.cdc_filter);
} else
goto fail;
return 0;
fail:
return -EINVAL;
}
static void rndis_disable(struct usb_function *f)
{
struct f_rndis *rndis = func_to_rndis(f);
struct usb_composite_dev *cdev = f->config->cdev;
if (!rndis->notify->driver_data)
return;
DBG(cdev, "rndis deactivated\n");
rndis_uninit(rndis->config);
gether_disconnect(&rndis->port);
usb_ep_disable(rndis->notify);
rndis->notify->driver_data = NULL;
}
/*-------------------------------------------------------------------------*/
/*
* This isn't quite the same mechanism as CDC Ethernet, since the
* notification scheme passes less data, but the same set of link
* states must be tested. A key difference is that altsettings are
* not used to tell whether the link should send packets or not.
*/
static void rndis_open(struct gether *geth)
{
struct f_rndis *rndis = func_to_rndis(&geth->func);
struct usb_composite_dev *cdev = geth->func.config->cdev;
DBG(cdev, "%s\n", __func__);
rndis_set_param_medium(rndis->config, RNDIS_MEDIUM_802_3,
bitrate(cdev->gadget) / 100);
rndis_signal_connect(rndis->config);
}
static void rndis_close(struct gether *geth)
{
struct f_rndis *rndis = func_to_rndis(&geth->func);
DBG(geth->func.config->cdev, "%s\n", __func__);
rndis_set_param_medium(rndis->config, RNDIS_MEDIUM_802_3, 0);
rndis_signal_disconnect(rndis->config);
}
/*-------------------------------------------------------------------------*/
/* Some controllers can't support RNDIS ... */
static inline bool can_support_rndis(struct usb_configuration *c)
{
/* everything else is *presumably* fine */
return true;
}
/* ethernet function driver setup/binding */
static int
rndis_bind(struct usb_configuration *c, struct usb_function *f)
{
struct usb_composite_dev *cdev = c->cdev;
struct f_rndis *rndis = func_to_rndis(f);
struct usb_string *us;
int status;
struct usb_ep *ep;
#ifndef USB_FRNDIS_INCLUDED
struct f_rndis_opts *rndis_opts;
if (!can_support_rndis(c))
return -EINVAL;
rndis_opts = container_of(f->fi, struct f_rndis_opts, func_inst);
/*
* in drivers/usb/gadget/configfs.c:configfs_composite_bind()
* configurations are bound in sequence with list_for_each_entry,
* in each configuration its functions are bound in sequence
* with list_for_each_entry, so we assume no race condition
* with regard to rndis_opts->bound access
*/
if (!rndis_opts->bound) {
gether_set_gadget(rndis_opts->net, cdev->gadget);
status = gether_register_netdev(rndis_opts->net);
if (status)
return status;
rndis_opts->bound = true;
}
#endif
us = usb_gstrings_attach(cdev, rndis_strings,
ARRAY_SIZE(rndis_string_defs));
if (IS_ERR(us))
return PTR_ERR(us);
rndis_control_intf.iInterface = us[0].id;
rndis_data_intf.iInterface = us[1].id;
rndis_iad_descriptor.iFunction = us[2].id;
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
if (status < 0)
goto fail;
rndis->ctrl_id = status;
rndis_iad_descriptor.bFirstInterface = status;
rndis_control_intf.bInterfaceNumber = status;
rndis_union_desc.bMasterInterface0 = status;
status = usb_interface_id(c, f);
if (status < 0)
goto fail;
rndis->data_id = status;
rndis_data_intf.bInterfaceNumber = status;
rndis_union_desc.bSlaveInterface0 = status;
status = -ENODEV;
/* allocate instance-specific endpoints */
ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc);
if (!ep)
goto fail;
rndis->port.in_ep = ep;
ep->driver_data = cdev; /* claim */
ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc);
if (!ep)
goto fail;
rndis->port.out_ep = ep;
ep->driver_data = cdev; /* claim */
/* NOTE: a status/notification endpoint is, strictly speaking,
* optional. We don't treat it that way though! It's simpler,
* and some newer profiles don't treat it as optional.
*/
ep = usb_ep_autoconfig(cdev->gadget, &fs_notify_desc);
if (!ep)
goto fail;
rndis->notify = ep;
ep->driver_data = cdev; /* claim */
status = -ENOMEM;
/* allocate notification request and buffer */
rndis->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL);
if (!rndis->notify_req)
goto fail;
rndis->notify_req->buf = kmalloc(STATUS_BYTECOUNT, GFP_KERNEL);
if (!rndis->notify_req->buf)
goto fail;
rndis->notify_req->length = STATUS_BYTECOUNT;
rndis->notify_req->context = rndis;
rndis->notify_req->complete = rndis_response_complete;
/* support all relevant hardware speeds... we expect that when
* hardware is dual speed, all bulk-capable endpoints work at
* both speeds
*/
hs_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress;
hs_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress;
hs_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress;
ss_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress;
ss_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress;
ss_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress;
status = usb_assign_descriptors(f, eth_fs_function, eth_hs_function,
eth_ss_function);
if (status)
goto fail;
rndis->port.open = rndis_open;
rndis->port.close = rndis_close;
#ifdef USB_FRNDIS_INCLUDED
status = rndis_register(rndis_response_available, rndis);
if (status < 0)
goto fail;
rndis->config = status;
#endif
rndis_set_param_medium(rndis->config, RNDIS_MEDIUM_802_3, 0);
rndis_set_host_mac(rndis->config, rndis->ethaddr);
rndis_set_max_pkt_xfer(rndis->config, rndis_ul_max_pkt_per_xfer);
if (rndis->manufacturer && rndis->vendorID &&
rndis_set_param_vendor(rndis->config, rndis->vendorID,
rndis->manufacturer))
goto fail;
/* NOTE: all that is done without knowing or caring about
* the network link ... which is unavailable to this code
* until we're activated via set_alt().
*/
DBG(cdev, "RNDIS: %s speed IN/%s OUT/%s NOTIFY/%s\n",
gadget_is_superspeed(c->cdev->gadget) ? "super" :
gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
rndis->port.in_ep->name, rndis->port.out_ep->name,
rndis->notify->name);
return 0;
fail:
usb_free_all_descriptors(f);
if (rndis->notify_req) {
kfree(rndis->notify_req->buf);
usb_ep_free_request(rndis->notify, rndis->notify_req);
}
/* we might as well release our claims on endpoints */
if (rndis->notify)
rndis->notify->driver_data = NULL;
if (rndis->port.out_ep)
rndis->port.out_ep->driver_data = NULL;
if (rndis->port.in_ep)
rndis->port.in_ep->driver_data = NULL;
ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
return status;
}
static void
rndis_old_unbind(struct usb_configuration *c, struct usb_function *f)
{
struct f_rndis *rndis = func_to_rndis(f);
rndis_deregister(rndis->config);
usb_free_all_descriptors(f);
kfree(rndis->notify_req->buf);
usb_ep_free_request(rndis->notify, rndis->notify_req);
kfree(rndis);
}
int
rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
u32 vendorID, const char *manufacturer, struct eth_dev *dev)
{
struct f_rndis *rndis;
int status;
/* allocate and initialize one new instance */
status = -ENOMEM;
rndis = kzalloc(sizeof *rndis, GFP_KERNEL);
if (!rndis)
goto fail;
memcpy(rndis->ethaddr, ethaddr, ETH_ALEN);
rndis->vendorID = vendorID;
rndis->manufacturer = manufacturer;
rndis->port.ioport = dev;
/* RNDIS activates when the host changes this filter */
rndis->port.cdc_filter = 0;
/* RNDIS has special (and complex) framing */
rndis->port.header_len = sizeof(struct rndis_packet_msg_type);
rndis->port.wrap = rndis_add_header;
rndis->port.unwrap = rndis_rm_hdr;
rndis->port.ul_max_pkts_per_xfer = rndis_ul_max_pkt_per_xfer;
rndis->port.dl_max_pkts_per_xfer = rndis_dl_max_pkt_per_xfer;
rndis->port.func.name = "rndis";
/* descriptors are per-instance copies */
rndis->port.func.bind = rndis_bind;
rndis->port.func.unbind = rndis_old_unbind;
rndis->port.func.set_alt = rndis_set_alt;
rndis->port.func.setup = rndis_setup;
rndis->port.func.disable = rndis_disable;
status = usb_add_function(c, &rndis->port.func);
if (status)
kfree(rndis);
fail:
return status;
}
void rndis_borrow_net(struct usb_function_instance *f, struct net_device *net)
{
struct f_rndis_opts *opts;
opts = container_of(f, struct f_rndis_opts, func_inst);
if (opts->bound)
gether_cleanup(netdev_priv(opts->net));
else
free_netdev(opts->net);
opts->borrowed_net = opts->bound = true;
opts->net = net;
}
EXPORT_SYMBOL(rndis_borrow_net);
static inline struct f_rndis_opts *to_f_rndis_opts(struct config_item *item)
{
return container_of(to_config_group(item), struct f_rndis_opts,
func_inst.group);
}
/* f_rndis_item_ops */
USB_ETHERNET_CONFIGFS_ITEM(rndis);
/* f_rndis_opts_dev_addr */
USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(rndis);
/* f_rndis_opts_host_addr */
USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(rndis);
/* f_rndis_opts_qmult */
USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis);
/* f_rndis_opts_ifname */
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis);
static struct configfs_attribute *rndis_attrs[] = {
&f_rndis_opts_dev_addr.attr,
&f_rndis_opts_host_addr.attr,
&f_rndis_opts_qmult.attr,
&f_rndis_opts_ifname.attr,
NULL,
};
static struct config_item_type rndis_func_type = {
.ct_item_ops = &rndis_item_ops,
.ct_attrs = rndis_attrs,
.ct_owner = THIS_MODULE,
};
static void rndis_free_inst(struct usb_function_instance *f)
{
struct f_rndis_opts *opts;
opts = container_of(f, struct f_rndis_opts, func_inst);
if (!opts->borrowed_net) {
if (opts->bound)
gether_cleanup(netdev_priv(opts->net));
else
free_netdev(opts->net);
}
kfree(opts);
}
static struct usb_function_instance *rndis_alloc_inst(void)
{
struct f_rndis_opts *opts;
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
mutex_init(&opts->lock);
opts->func_inst.free_func_inst = rndis_free_inst;
opts->net = gether_setup_default();
if (IS_ERR(opts->net)) {
struct net_device *net = opts->net;
kfree(opts);
return ERR_CAST(net);
}
config_group_init_type_name(&opts->func_inst.group, "",
&rndis_func_type);
return &opts->func_inst;
}
static void rndis_free(struct usb_function *f)
{
struct f_rndis *rndis;
struct f_rndis_opts *opts;
rndis = func_to_rndis(f);
rndis_deregister(rndis->config);
opts = container_of(f->fi, struct f_rndis_opts, func_inst);
kfree(rndis);
mutex_lock(&opts->lock);
opts->refcnt--;
mutex_unlock(&opts->lock);
}
static void rndis_unbind(struct usb_configuration *c, struct usb_function *f)
{
struct f_rndis *rndis = func_to_rndis(f);
usb_free_all_descriptors(f);
kfree(rndis->notify_req->buf);
usb_ep_free_request(rndis->notify, rndis->notify_req);
}
static struct usb_function *rndis_alloc(struct usb_function_instance *fi)
{
struct f_rndis *rndis;
struct f_rndis_opts *opts;
int status;
/* allocate and initialize one new instance */
rndis = kzalloc(sizeof(*rndis), GFP_KERNEL);
if (!rndis)
return ERR_PTR(-ENOMEM);
opts = container_of(fi, struct f_rndis_opts, func_inst);
mutex_lock(&opts->lock);
opts->refcnt++;
gether_get_host_addr_u8(opts->net, rndis->ethaddr);
rndis->vendorID = opts->vendor_id;
rndis->manufacturer = opts->manufacturer;
rndis->port.ioport = netdev_priv(opts->net);
mutex_unlock(&opts->lock);
/* RNDIS activates when the host changes this filter */
rndis->port.cdc_filter = 0;
/* RNDIS has special (and complex) framing */
rndis->port.header_len = sizeof(struct rndis_packet_msg_type);
rndis->port.wrap = rndis_add_header;
rndis->port.unwrap = rndis_rm_hdr;
rndis->port.func.name = "rndis";
/* descriptors are per-instance copies */
rndis->port.func.bind = rndis_bind;
rndis->port.func.unbind = rndis_unbind;
rndis->port.func.set_alt = rndis_set_alt;
rndis->port.func.setup = rndis_setup;
rndis->port.func.disable = rndis_disable;
rndis->port.func.free_func = rndis_free;
status = rndis_register(rndis_response_available, rndis);
if (status < 0) {
kfree(rndis);
return ERR_PTR(status);
}
rndis->config = status;
return &rndis->port.func;
}
DECLARE_USB_FUNCTION(rndis, rndis_alloc_inst, rndis_alloc);
static int __init rndis_mod_init(void)
{
int ret;
ret = rndis_init();
if (ret)
return ret;
return usb_function_register(&rndisusb_func);
}
module_init(rndis_mod_init);
static void __exit rndis_mod_exit(void)
{
usb_function_unregister(&rndisusb_func);
rndis_exit();
}
module_exit(rndis_mod_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Brownell");
|
acorn-marvell/brillo_pxa_kernel
|
drivers/usb/gadget/f_rndis.c
|
C
|
gpl-2.0
| 32,284 |
<?php
/*
* @version $Id: knowbaseitemcategory.class.php 14684 2011-06-11 06:32:40Z remi $
-------------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2011 by the INDEPNET Development Team.
http://indepnet.net/ http://glpi-project.org
-------------------------------------------------------------------------
LICENSE
This file is part of GLPI.
GLPI 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.
GLPI 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 GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Remi Collet
// Purpose of file:
// ----------------------------------------------------------------------
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
}
/// Class KnowbaseItemCategory
class KnowbaseItemCategory extends CommonTreeDropdown {
function canCreate() {
return haveRight('entity_dropdown', 'w');
}
function canView() {
return haveRight('entity_dropdown', 'r');
}
static function getTypeName() {
global $LANG;
return $LANG['setup'][87];
}
/**
* Report if a dropdown have Child
* Used to (dis)allow delete action
**/
function haveChildren() {
if (parent::haveChildren()) {
return true;
}
$kb = new KnowbaseItem();
$fk = $this->getForeignKeyField();
$id = $this->fields['id'];
return (countElementsInTable($kb->getTable(),"`$fk`='$id'")>0);
}
/**
* Show KB categories
*
* @param $options : $_GET
* @param $faq display on faq ?
*
* @return nothing (display the form)
**/
static function showFirstLevel($options, $faq=0) {
global $DB, $LANG, $CFG_GLPI;
// Default values of parameters
$params["knowbaseitemcategories_id"] = "0";
$params["target"] = $_SERVER['PHP_SELF'];
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$params[$key]=$val;
}
}
$faq_limit = '';
if ($faq) {
if (!$CFG_GLPI["use_public_faq"] && !haveRight("faq","r")) {
return false;
}
if (getLoginUserID()) {
$faq_limit = getEntitiesRestrictRequest("AND", "glpi_knowbaseitemcategories", "", "",
true);
} else {
// Anonymous access
if (isMultiEntitiesMode()) {
$faq_limit = " AND (`glpi_knowbaseitemcategories`.`entities_id` = '0'
AND `glpi_knowbaseitemcategories`.`is_recursive` = '1')";
}
}
// Get All FAQ categories
if (!isset($_SESSION['glpi_faqcategories'])) {
$_SESSION['glpi_faqcategories'] = '(0)';
$tmp = array();
$query = "SELECT DISTINCT `glpi_knowbaseitems`.`knowbaseitemcategories_id`
FROM `glpi_knowbaseitems`
LEFT JOIN `glpi_knowbaseitemcategories`
ON (`glpi_knowbaseitemcategories`.`id`
= `glpi_knowbaseitems`.`knowbaseitemcategories_id`)
WHERE `glpi_knowbaseitems`.`is_faq` = '1'
$faq_limit";
if ($result=$DB->query($query)) {
if ($DB->numrows($result)) {
while ($data=$DB->fetch_array($result)) {
if (!in_array($data['knowbaseitemcategories_id'], $tmp)) {
$tmp[] = $data['knowbaseitemcategories_id'];
$tmp = array_merge($tmp,
getAncestorsOf('glpi_knowbaseitemcategories',
$data['knowbaseitemcategories_id']));
}
}
}
if (count($tmp)) {
$_SESSION['glpi_faqcategories'] = "('".implode("','",$tmp)."')";
}
}
}
$query = "SELECT DISTINCT `glpi_knowbaseitemcategories`.*
FROM `glpi_knowbaseitemcategories`
WHERE `id` IN ".$_SESSION['glpi_faqcategories']."
AND (`glpi_knowbaseitemcategories`.`knowbaseitemcategories_id`
= '".$params["knowbaseitemcategories_id"]."')
$faq_limit
ORDER BY `name` ASC";
} else {
if (!haveRight("knowbase", "r")) {
return false;
}
$faq_limit = getEntitiesRestrictRequest("AND", "glpi_knowbaseitemcategories", "entities_id",
$_SESSION['glpiactiveentities'], true);
$query = "SELECT *
FROM `glpi_knowbaseitemcategories`
WHERE `glpi_knowbaseitemcategories`.`knowbaseitemcategories_id`
= '".$params["knowbaseitemcategories_id"]."'
$faq_limit
ORDER BY `name` ASC";
}
// Show category
if ($result=$DB->query($query)) {
echo "<table class='tab_cadre_central'>";
echo "<tr><td colspan='3'><a href='".$params['target']."'>";
echo "<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/folder-open.png' class='bottom'></a>";
// Display Category
if ($params["knowbaseitemcategories_id"]!=0) {
$tmpID = $params["knowbaseitemcategories_id"];
$todisplay = "";
while ($tmpID!=0) {
$query2 = "SELECT *
FROM `glpi_knowbaseitemcategories`
WHERE `id` = '$tmpID'
$faq_limit";
$result2 = $DB->query($query2);
if ($DB->numrows($result2)==1) {
$data = $DB->fetch_assoc($result2);
$tmpID = $data["knowbaseitemcategories_id"];
$todisplay = "<a href='".$params['target']."?knowbaseitemcategories_id=".
$data["id"]."'>".$data["name"]."</a>".(empty($todisplay)?"":" > ").
$todisplay;
} else {
$tmpID = 0;
}
}
echo " > ".$todisplay;
}
if ($DB->numrows($result)>0) {
$i = 0;
while ($row=$DB->fetch_array($result)) {
// on affiche les résultats sur trois colonnes
if ($i%3==0) {
echo "<tr>";
}
$ID = $row["id"];
echo "<td class='tdkb_result'>";
echo "<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/folder.png' hspace='5'>";
echo "<strong><a href='".$params['target']."?knowbaseitemcategories_id=".$row["id"]."'>".
$row["name"]."</a></strong>";
echo "<div class='kb_resume'>".resume_text($row['comment'],60)."</div>";
if ($i%3==2) {
echo "</tr>";
}
$i++;
}
}
echo "<tr><td colspan='3'> </td></tr></table><br>";
}
}
}
?>
|
ardowz/Thesis-SideB
|
inc/knowbaseitemcategory.class.php
|
PHP
|
gpl-2.0
| 7,984 |
#!/bin/bash
git clone https://git.gitorious.org/bangarang/bangarang.git || exit 1
pushd bangarang
sed -i 's/system@//g' .gitmodules
git submodule init || exit 1
git submodule update || exit 1
find . -name .git|xargs rm -rf
popd
mv bangarang bangarang-git$1
tar --remove-files -cJvf bangarang-git$1.tar.xz bangarang-git$1
|
MagicGroup/MagicSPECS
|
SPECS.b/bangarang/make_bangarang_git_package.sh
|
Shell
|
gpl-2.0
| 324 |
package EPrints::Plugin::Stats::Processor::Access::Browsers;
our @ISA = qw/ EPrints::Plugin::Stats::Processor::Access /;
use strict;
# Processor::Access::Browsers
#
# Processes the User agents from Access records. Provides the 'eprint_browsers' datatype
#
our $BROWSERS_SIGNATURES = {
'; AOL' => 'AOL',
'Chrome\/' => 'Google Chrome',
'Elinks\/' => 'Elinks',
'Firefox\/' => 'Firefox',
'; MSIE ' => 'Microsoft Internet Explorer',
'Netscape\/' => 'Netscape',
'Navigator\/' => 'Netscape',
'Safari\/' => 'Apple Safari',
'; Android ' => 'Android',
'\(BlackBerry;' => 'BlackBerry',
'Opera\/' => 'Opera',
'; Opera Mobi\/' => 'Opera Mobile',
};
sub new
{
my( $class, %params ) = @_;
my $self = $class->SUPER::new( %params );
$self->{provides} = [ "browsers" ];
$self->{disable} = 0;
$self->{cache} = {};
# still used?!
$self->{conf} = {
fields => [ 'value' ],
render => 'string',
};
return $self;
}
sub process_record
{
my ($self, $record, $is_download) = @_;
my $epid = $record->{referent_id};
return unless( defined $epid );
my $ua = $record->{requester_user_agent};
return unless( EPrints::Utils::is_set( $ua ) );
foreach( keys %$BROWSERS_SIGNATURES )
{
if( $ua =~ $_ )
{
my $date = $record->{datestamp}->{cache};
$self->{cache}->{"$date"}->{$epid}->{$BROWSERS_SIGNATURES->{$_}}++;
last;
}
}
}
1;
|
UB-Bern/boris
|
lib/plugins/EPrints/Plugin/Stats/Processor/Access/Browsers.pm
|
Perl
|
gpl-2.0
| 1,410 |
<?php
/**IH4-1
* mod Image Handler 5.1.0
* ih_manager.php
* manager module for IH4 admin interface
*
* @author Tim Kroeger (original author)
* @copyright Copyright 2005-2006
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License V2.0
* @version $Id: ih_manager.php,v 2.0 Rev 8 2010-05-31 23:46:5 DerManoMann Exp $
* Last modified by DerManoMann 2010-05-31 23:46:50
* Re-factored for IH-5 by lat9 2017-12-02
* Restructuring for IH-5.1.0 and later by lat9, 2018-05-22.
*/
if ($action === 'new_cat') {
$current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
$new_product_query = $db->Execute(
"SELECT ptc.* FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
ON ptc.products_id = pd.products_id
AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
WHERE ptc.categories_id = " . (int)$current_category_id . "
ORDER BY pd.products_name"
);
$products_filter = ($new_product_query->EOF) ? null : $new_product_query->fields['products_id'];
zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER, 'ih_page=manager&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
}
// set categories and products if not set
if ($products_filter == '' && $current_category_id > 0) {
$new_product_query = $db->Execute(
"SELECT ptc.* FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
ON ptc.products_id = pd.products_id
AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
WHERE ptc.categories_id = " . (int)$current_category_id . "
ORDER BY pd.products_name"
);
$products_filter = $new_product_query->fields['products_id'];
if ($products_filter != '') {
zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER, 'ih_page=manager&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
}
} else {
if ($products_filter == '' && $current_category_id == '') {
$reset_categories_id = zen_get_category_tree('', '', '0', '', '', true);
$current_category_id = $reset_categories_id[0]['id'];
$new_product_query = $db->Execute(
"SELECT ptc.* from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
ON ptc.products_id = pd.products_id
AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
WHERE ptc.categories_id = " . (int)$current_category_id . "
ORDER BY pd.products_name"
);
$products_filter = ($new_product_query->EOF) ? null : $new_product_query->fields['products_id'];
$_GET['products_filter'] = $products_filter;
}
}
require DIR_WS_MODULES . FILENAME_PREV_NEXT;
// -----
// Note: On entry, if a product has been selected, the main image_handler module has created the $products
// variable, containing the database information associated with the selected product's image. The
// information in that array will be used to determine the product's base-name as well as its base
// image directory.
//
// If a product has **not** been selected, simply return from this module back to the main handler,
// since no actions are possible.
//
if (!isset($product)) {
return;
}
// -----
// Set the images' directory, using the values specified in the $ihConf array.
//
$images_directory = $ihConf['dir']['docroot'] . $ihConf['dir']['images'];
// -----
// The "save" form gathers up to three (3) separate image files: base, medium and large. That form is used
// for two different cases:
//
// 1) Uploading a new image, either:
// a) A main product-image, for a product that does not yet have a products_image defined.
// - In this case, $_GET['imgNew'] is set to 'main'.
// b) An additional product-image, when the product has its main image defined.
// - In this case, $_GET['imgNew'] is set to 'addl'
// 2) Modifying an existing image.
// - In this case, $_GET['imgNew'] is *not* supplied, but $_GET['imgSuffix'] will identify
// the "image-suffix" being edited; if the value is empty, it's the main image being edited.
//
// There are a couple of "rules" associated with those uploaded images:
//
// 1) If the associated product DOES NOT currently have an image, the base image is **required**.
// 2) The file-extension of any medium or large image is controlled by their respective Configuration->Images
// configuration settings. Those values are one of 'png', 'jpg', 'gif', or 'no_change'. If the value is
// set to 'no_change', the medium/large image is the same file-extension as the main-product image.
//
if ($action === 'save') {
// -----
// Log the input values on entry, if debug is enabled.
//
$ih_admin->debugLog(
'ih_manager/save, on entry.' . PHP_EOL .
'$_GET:' . PHP_EOL . var_export($_GET, true) . PHP_EOL .
'$_POST:' . PHP_EOL . var_export($_POST, true) . PHP_EOL .
'$_FILES:' . PHP_EOL . var_export($_FILES, true)
);
// -----
// If the "saveType" wasn't supplied with the form, redirect back to the main IH
// manager page without message (since it "shouldn't" happen).
//
if (empty($_POST['saveType'])) {
zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER));
}
// -----
// Initialize some internal "handling" variables.
//
$data = array();
$data_ok = true;
$keep_name = false;
$editing = false;
$is_main = false;
$new_main_image = false;
$uploaded_default_extension = false;
$uploaded_medium_extension = false;
$uploaded_large_extension = false;
// -----
// Verify that any uploaded images' file-extension is one of those 'allowed'.
//
$supported_extensions = $ih_admin->getSupportedFileExtensions();
// -----
// If a default/base image was uploaded, make sure that its file-extension is 'allowed'.
//
if (!empty($_FILES['default_image']['name'])) {
$uploaded_default_extension = '.' . pathinfo($_FILES['default_image']['name'], PATHINFO_EXTENSION);
if (!$ih_admin->validateFileExtension($uploaded_default_extension)) {
$messageStack->add(sprintf(TEXT_MSG_INVALID_EXTENSION, TEXT_BASE, $uploaded_default_extension, $supported_extensions), 'error');
$data_ok = false;
}
}
// -----
// If a medium or large image was uploaded, make sure that its file-extension is also 'allowed'.
//
if (!empty($_FILES['medium_image']['name'])) {
$uploaded_medium_extension = '.' . pathinfo($_FILES['medium_image']['name'], PATHINFO_EXTENSION);
if (!$ih_admin->validateFileExtension($uploaded_medium_extension)) {
$messageStack->add(sprintf(TEXT_MSG_INVALID_EXTENSION, TEXT_MEDIUM, $uploaded_medium_extension, $supported_extensions), 'error');
$data_ok = false;
}
}
if (!empty($_FILES['large_image']['name'])) {
$uploaded_large_extension = '.' . pathinfo($_FILES['large_image']['name'], PATHINFO_EXTENSION);
if (!$ih_admin->validateFileExtension($uploaded_large_extension)) {
$messageStack->add(sprintf(TEXT_MSG_INVALID_EXTENSION, TEXT_LARGE, $uploaded_large_extension, $supported_extensions), 'error');
$data_ok = false;
}
}
// -----
// If any of the uploaded files' extensions were found to be 'invalid', simply return to the main
// image_handler processing for display.
//
if (!$data_ok) {
return;
}
// -----
// Otherwise, set some processing flags and gather information, based on the type of image being saved.
//
switch ($_POST['saveType']) {
// -----
// Updating an existing image.
//
case 'edit':
if (!isset($_POST['imgSuffix'])) {
$data_ok = false;
} else {
$editing = true;
$data['imgSuffix'] = $_POST['imgSuffix'];
$data['imgBaseDir'] = $products_image_directory;
$is_main = ($_POST['imgSuffix'] == '');
$keep_name = (isset($_POST['imgNaming']) && $_POST['imgNaming'] === 'keep_name');
if ($is_main && !$keep_name) {
if (empty($_FILES['default_image']['name'])) {
$messageStack->add(TEXT_MSG_NO_DEFAULT_ON_NAME_CHANGE, 'error');
$data_ok = false;
} else {
$data['imgBase'] = pathinfo($_FILES['default_image']['name'], PATHINFO_FILENAME);
$data['imgExtension'] = $uploaded_default_extension;
}
} else {
$data['imgBase'] = $products_image_base;
$data['imgExtension'] = $products_image_extension;
}
}
break;
// -----
// Creating a new, main image. There are additional variables passed in that version of the
// data-gathering form.
//
// - imgBase ....... The "base" name for the image, overriding the name associated with any uploaded image.
// - imgBaseDir .... The "base" directory for the image, selected from existing image-directory sub-directories.
// - imgNewBaseDir . A new sub-directory to be created under the image-directory for this image.
//
case 'new_main':
$is_main = true;
$new_main_image = true;
if (!empty($_POST['imgBase'])) {
$data['imgBase'] = $_POST['imgBase'];
if (!empty($uploaded_default_extension)) {
$data['imgExtension'] = $uploaded_default_extension;
} else {
$messageStack->add(TEXT_MSG_NO_FILE_UPLOADED, 'error');
$data_ok = false;
}
} else {
if (empty($_FILES['default_image']['name'])) {
$messageStack->add(TEXT_MSG_AUTO_BASE_ERROR, 'error');
$data_ok = false;
} else {
$data['imgBase'] = pathinfo($_FILES['default_image']['name'], PATHINFO_FILENAME);
$data['imgExtension'] = $uploaded_default_extension;
}
}
if (!empty($_POST['imgNewBaseDir'])) {
$data['imgBaseDir'] = $_POST['imgNewBaseDir'];
$base_is_new = true;
} else {
$data['imgBaseDir'] = $_POST['imgBaseDir'];
$base_is_new = false;
}
$data['imgSuffix'] = '';
break;
// -----
// Creating a new additional image for a product. The image is created in the same directory
// with the same name as the default/main image.
//
// The 'imgSuffix' variable, if specified, identifies the suffix (e.g. _01) to apply to this
// additional image. If the value is not supplied, determine the next available suffix (in the
// range _01 to _99 to apply to this image.
//
case 'new_addl':
if ($_FILES['default_image']['name'] == '') {
$messageStack->add(TEXT_MSG_NO_DEFAULT, 'error');
$data_ok = false;
} else {
$data['imgBaseDir'] = $products_image_directory;
$data['imgBase'] = $products_image_base;
$data['imgExtension'] = $uploaded_default_extension;
if ($_POST['imgSuffix'] != '') {
$data['imgSuffix'] = '_' . $_POST['imgSuffix'];
} else {
// -----
// Get additional images' list; the class function takes care of sorting the files
//
$matching_files = array();
$ih_admin->findAdditionalImages($matching_files, $data['imgBaseDir'], $data['imgBase']);
// -----
// Log the input values on entry, if debug is enabled.
//
$ih_admin->debugLog(
'ih_manager/save, additional images' . PHP_EOL . var_export($matching_files, true) . PHP_EOL . var_export($data, true)
);
// -----
// If no additional images exist, use the _01 suffix.
//
$file_count = count($matching_files);
if ($file_count == 1) {
$data['imgSuffix'] = '_01';
} else {
// -----
// Otherwise, find the first unused suffix in the range _01 to _99. Note that the first
// (ignored) element of the find-array "should be" the main image's name!
//
for ($suffix = 1, $found = false; $suffix < 99; $suffix++) {
$suffix_string = sprintf('_%02u', $suffix);
if (!in_array($data['imgBase'] . $suffix_string . $data['imgExtension'], $matching_files)) {
$found = true;
$data['imgSuffix'] = $suffix_string;
break;
}
}
if (!$found) {
$messageStack->add(TEXT_MSG_NO_SUFFIXES_FOUND, 'error');
$data_ok = false;
}
}
}
}
break;
default:
$data_ok = false;
break;
}
// -----
// If the data supplied appears OK, perform a couple of pre-processing checks.
//
if ($data_ok) {
// -----
// Correct some "nasty" characters in the image's name.
//
if (strpos($data['imgBase'], '+') !== false) {
$data['imgBase'] = str_replace('+', '-', $data['imgBase']);
$messageStack->add(TEXT_MSG_AUTO_REPLACE . $data['imgBase'], 'warning');
}
// -----
// If the image's base-directory doesn't currently end in either a / or \, append a / to that value.
//
if ($data['imgBaseDir'] != '') {
if (substr($data['imgBaseDir'], -1) != '/' && substr($data['imgBaseDir'], -1) != '\\') {
$data['imgBaseDir'] .= '/';
}
}
// -----
// Create the name of the base image file, less the store's specific images directory.
//
$data['defaultFileName'] = $data['imgBaseDir'] . $data['imgBase'] . $data['imgSuffix'] . $data['imgExtension'];
// -----
// If a **main** image is being edited (i.e. its name is being changed) and the new file already exists, disallow
// the change.
//
if ($editing && $is_main && !$keep_name && file_exists($images_directory . $data['defaultFileName'])) {
$existing_file = $images_directory . $data['defaultFileName'];
$messageStack->add(sprintf(TEXT_MSG_FILE_EXISTS, $existing_file), 'error' );
$data_ok = false;
}
}
// -----
// If no previous errors and we're either (a) creating a new main-image or (b) editing the main-image and a new name
// is requested ...
//
if ($data_ok && ($new_main_image || ($editing && $is_main && !$keep_name))) {
// -----
// ... first, check to see that the image's name is going to fit into the database field.
//
if (strlen($data['defaultFileName']) > zen_field_length(TABLE_PRODUCTS, 'products_image')) {
$messageStack->add(sprintf(TEXT_MSG_NAME_TOO_LONG_ERROR, $data['defaultFileName'], zen_field_length(TABLE_PRODUCTS, 'products_image')), 'error');
$data_ok = false;
} else {
$db->Execute(
"UPDATE " . TABLE_PRODUCTS . "
SET products_image = '" . $db->prepare_input($data['defaultFileName']) . "'
WHERE products_id = " . (int)$products_filter . "
LIMIT 1"
);
}
}
// -----
// ... finally (!) create the images based on the validated user-input. For each
// image-type supplied, create the file in destination directory and move the
// uploaded file to that destination.
//
if ($data_ok) {
$ih_admin->debugLog("images_directory: $images_directory, data: " . PHP_EOL . var_export($data, true));
// -----
// The "base" image ...
//
if ($_FILES['default_image']['name'] != '') {
io_makeFileDir($images_directory . $data['defaultFileName']);
$source_name = $_FILES['default_image']['tmp_name'];
$destination_name = $images_directory . $data['defaultFileName'];
if (!move_uploaded_file($source_name, $destination_name)) {
$messageStack->add(TEXT_MSG_NOUPLOAD_DEFAULT, 'error' );
$data_ok = false;
}
}
// -----
// The "medium" image ...
//
if ($data_ok && $_FILES['medium_image']['name'] != '') {
$medium_filename = 'medium/' . $data['imgBaseDir'] . $data['imgBase'] . $data['imgSuffix'] . IMAGE_SUFFIX_MEDIUM . $uploaded_medium_extension;
io_makeFileDir($images_directory . $medium_filename);
$source_name = $_FILES['medium_image']['tmp_name'];
$destination_name = $images_directory . $medium_filename;
if (!move_uploaded_file($source_name, $destination_name)) {
$messageStack->add(TEXT_MSG_NOUPLOAD_MEDIUM, 'error');
$data_ok = false;
}
}
// -----
// The "large" image ...
//
if ($data_ok && $_FILES['large_image']['name'] != '') {
$large_filename = 'large/' . $data['imgBaseDir'] . $data['imgBase'] . $data['imgSuffix'] . IMAGE_SUFFIX_LARGE . $uploaded_large_extension;
io_makeFileDir($images_directory . $large_filename);
$source_name = $_FILES['large_image']['tmp_name'];
$destination_name = $images_directory . $large_filename;
if (!move_uploaded_file($source_name, $destination_name)) {
$messageStack->add(TEXT_MSG_NOUPLOAD_LARGE, 'error');
$data_ok = false;
}
}
}
if (!$data_ok) {
if ($editing) {
$action = "layout_edit";
} else {
$action = "layout_new";
}
} else {
$messageStack->add_session(TEXT_MSG_IMAGE_SAVED, 'success');
$redirect_parms = zen_get_all_get_params(array('action', 'imgName', 'imgSuffix', 'imgExtension'));
$redirect_parms .= '&imgName=' . $data['imgBase'] . $data['imgSuffix'];
$redirect_parms .= '&imgSuffix=' . $data['imgSuffix'];
$redirect_parms .= '&imgExtension=' . $data['imgExtension'];
zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER, $redirect_parms . '&action=layout_info'));
}
}
// -----
// A 'quick_delete' action enables the removal of a medium/large image file that is different from
// the product's base image.
//
if ($action === 'quick_delete') {
if (!empty($_POST['qdFile'])) {
$img_name = DIR_FS_CATALOG . $_POST['qdFile'];
if (is_file($img_name)) {
if (unlink($img_name)) {
// file successfully deleted
$messageStack->add_session(sprintf(TEXT_MSG_IMAGE_DELETED, $img_name), 'success');
} else {
// couldn't delete file
$messageStack->add_session(sprintf(TEXT_MSG_IMAGE_NOT_DELETED, $img_name), 'error');
}
} else {
// could not find file to delete
$messageStack->add_session(sprintf(TEXT_MSG_IMAGE_NOT_FOUND, $img_name), 'error');
}
}
zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER, "products_filter=$products_filter&current_category_id=$current_category_id"));
}
// -----
// Delete a specified product image.
//
if ($action === 'delete') {
if (!empty($_POST['imgSuffix']) || empty($_POST['delete_from_db_only'])) {
$base_name = $products_image_directory . $_POST['imgName'];
$image_ext = $_POST['imgExtension'];
$large_file = $images_directory . 'large/' . $base_name . IMAGE_SUFFIX_LARGE . $image_ext;
if (is_file($large_file)) {
if (unlink($large_file)) {
$messageStack->add_session(sprintf(TEXT_MSG_LARGE_DELETED, $large_file), 'success');
} else {
$messageStack->add_session(sprintf(TEXT_MSG_NO_DELETE_LARGE, $large_file), 'error');
}
}
$medium_file = $images_directory . 'medium/' . $base_name . IMAGE_SUFFIX_MEDIUM . $image_ext;
if (is_file($medium_file)) {
if (unlink($medium_file)) {
$messageStack->add_session(sprintf(TEXT_MSG_MEDIUM_DELETED, $medium_file), 'success');
} else {
$messageStack->add_session(sprintf(TEXT_MSG_NO_DELETE_MEDIUM, $medium_file), 'error');
}
}
$base_file = $images_directory . $base_name . $image_ext;
if (!is_file($base_file)) {
$messageStack->add_session(sprintf(TEXT_MSG_NO_DEFAULT_FILE_FOUND, $base_file), 'error');
} else {
if (unlink($base_file)) {
$messageStack->add_session(sprintf(TEXT_MSG_DEFAULT_DELETED, $base_file), 'success');
} else {
$messageStack->add_session(sprintf(TEXT_MSG_NO_DELETE_DEFAULT, $base_file), 'error');
}
}
}
// update the database
if (empty($_POST['imgSuffix'])) {
$db->Execute(
"UPDATE " . TABLE_PRODUCTS . "
SET products_image = ''
WHERE products_id = " . (int)$products_filter . "
LIMIT 1"
);
}
zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER, "products_filter=$products_filter&current_category_id=$current_category_id"));
}
|
lat9/zen_Image-Handler
|
1_Installation_Files (v1.5.5)/YOUR_ADMIN/includes/ih_manager.php
|
PHP
|
gpl-2.0
| 22,362 |
#!/bin/bash
file="/etc/default/grub"
if ! test -f $file".original"; then
cp $file $file".original"
fi
updatetime=$(date +%Y%m%d-%T)
newfile=$file".laus."$updatetime
cp $file $newfile
## String ersetzen
#sed "/GRUB_HIDDEN_TIMEOUT_QUIET=true/ s/GRUB_HIDDEN_TIMEOUT_QUIET=true/#GRUB_HIDDEN_TIMEOUT_QUIET=true/" -i $newfile
#sed "/GRUB_HIDDEN_TIMEOUT=0/ s/GRUB_HIDDEN_TIMEOUT=0/#GRUB_HIDDEN_TIMEOUT=0/" -i $newfile
sed '/#GRUB_DISABLE_RECOVERY="true"/ s/#GRUB_DISABLE_RECOVERY="true"/GRUB_DISABLE_RECOVERY="true"/' -i $file
update-grub
|
edvapp/autoinstall
|
laus/scriptsForClasses/ZZZARCHIVE/APP/APP1604/110-hideRecoveryInGrub.sh
|
Shell
|
gpl-2.0
| 539 |
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : windowstack.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef WINDOWSTACK_H
#define WINDOWSTACK_H
#include "codelite_exports.h"
#include "wx/panel.h"
#include "wx/sizer.h"
#include <set>
#include <vector>
class WXDLLIMPEXP_SDK WindowStack : public wxWindow
{
std::vector<wxWindow*> m_windows;
wxWindow* m_activeWin = nullptr;
protected:
int FindPage(wxWindow* page) const;
void ChangeSelection(size_t index);
void DoSelect(wxWindow* win);
void OnSize(wxSizeEvent& e);
void DoHideNoActiveWindows();
public:
WindowStack(wxWindow* parent, wxWindowID id = wxID_ANY);
virtual ~WindowStack();
bool Add(wxWindow* win, bool select);
void Select(wxWindow* win);
void Clear();
bool Remove(wxWindow* win);
bool Contains(wxWindow* win);
bool IsEmpty() const { return m_windows.empty(); }
wxWindow* GetSelected() const;
};
#endif // WINDOWSTACK_H
|
srini2174/codelite
|
Plugin/windowstack.h
|
C
|
gpl-2.0
| 2,061 |
using System.Collections.Generic;
namespace eBdb.EpubReader {
public class NavPoint {
public string ID { get; private set; }
public string Title { get; private set; }
public string Source { get; private set; }
public int Order { get; private set; }
public ContentData ContentData { get; private set; }
public List<NavPoint> Children { get; private set; }
public NavPoint(string id, string title, string source, int order, ContentData contentData, List<NavPoint> children) {
ID = id;
Title = title;
Source = source;
Order = order;
ContentData = contentData;
Children = children;
}
}
}
|
lsmithmier/ePubReader.Portable
|
ePubReader/NavPoint.cs
|
C#
|
gpl-2.0
| 625 |
<?php
/**
* Copyright 2016, Google Inc. All Rights Reserved.
*
* 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.
*/
namespace Google\AdsApi\AdWords\Reporting\v201705;
use Google\AdsApi\AdWords\v201705\cm\Selector;
/**
* Represents a report definition containing its details, such as name, type,
* date range.
*/
final class ReportDefinition {
private $selector;
private $reportName;
private $reportType;
private $dateRangeType;
private $downloadFormat;
/**
* Creates a report definition instance with the specified properties.
*
* @param Selector $selector
* @param string $reportName
* @param string $reportType
* @param string $dateRangeType
* @param string $downloadFormat
*/
public function __construct(
Selector $selector = null,
$reportName = null,
$reportType = null,
$dateRangeType = null,
$downloadFormat = null
) {
$this->selector = $selector;
$this->reportName = $reportName;
$this->reportType = $reportType;
$this->dateRangeType = $dateRangeType;
$this->downloadFormat = $downloadFormat;
}
/**
* Gets the selector of the report definition.
*
* @see
* https://developers.google.com/adwords/api/docs/appendix/selectorfields#v201705
* @return Selector
*/
public function getSelector() {
return $this->selector;
}
/**
* Sets the selector of the report definition.
*
* @see
* https://developers.google.com/adwords/api/docs/appendix/selectorfields#v201705
* @param Selector $selector
*/
public function setSelector(Selector $selector) {
$this->selector = $selector;
}
/**
* Gets the report name.
*
* @return string
*/
public function getReportName() {
return $this->reportName;
}
/**
* Sets the report name.
*
* @param string $reportName
*/
public function setReportName($reportName) {
$this->reportName = $reportName;
}
/**
* Gets the report type.
*
* @return string
*/
public function getReportType() {
return $this->reportType;
}
/**
* Sets the report type.
*
* @param string $reportType
*/
public function setReportType($reportType) {
$this->reportType = $reportType;
}
/**
* Gets the date range type.
*
* @see
* https://developers.google.com/adwords/api/docs/guides/reporting#xml-schema-definition
* @return string
*/
public function getDateRangeType() {
return $this->dateRangeType;
}
/**
* Sets the date range type.
*
* @see
* https://developers.google.com/adwords/api/docs/guides/reporting#xml-schema-definition
* @param string $dateRangeType
*/
public function setDateRangeType($dateRangeType) {
$this->dateRangeType = $dateRangeType;
}
/**
* Gets the download format.
*
* @see
* https://developers.google.com/adwords/api/docs/guides/reporting#supported-download-formats
* @return string
*/
public function getDownloadFormat() {
return $this->downloadFormat;
}
/**
* Sets the download format.
*
* @see
* https://developers.google.com/adwords/api/docs/guides/reporting#supported-download-formats
* @param string $downloadFormat
*/
public function setDownloadFormat($downloadFormat) {
$this->downloadFormat = $downloadFormat;
}
}
|
renshuki/dfp-manager
|
vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/Reporting/v201705/ReportDefinition.php
|
PHP
|
gpl-2.0
| 3,840 |
/*
* ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter
*
* Written By: Brian King <[email protected]>, IBM Corporation
*
* Copyright (C) IBM Corporation, 2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _IBMVFC_H
#define _IBMVFC_H
#include <linux/list.h>
#include <linux/types.h>
#include "viosrp.h"
#define IBMVFC_NAME "ibmvfc"
#define IBMVFC_DRIVER_VERSION "1.0.4"
#define IBMVFC_DRIVER_DATE "(November 14, 2008)"
#define IBMVFC_DEFAULT_TIMEOUT 15
#define IBMVFC_INIT_TIMEOUT 120
#define IBMVFC_MAX_REQUESTS_DEFAULT 100
#define IBMVFC_DEBUG 0
#define IBMVFC_MAX_TARGETS 1024
#define IBMVFC_MAX_LUN 0xffffffff
#define IBMVFC_MAX_SECTORS 0xffffu
#define IBMVFC_MAX_DISC_THREADS 4
#define IBMVFC_TGT_MEMPOOL_SZ 64
#define IBMVFC_MAX_CMDS_PER_LUN 64
#define IBMVFC_MAX_HOST_INIT_RETRIES 6
#define IBMVFC_MAX_TGT_INIT_RETRIES 3
#define IBMVFC_DEV_LOSS_TMO (5 * 60)
#define IBMVFC_DEFAULT_LOG_LEVEL 2
#define IBMVFC_MAX_CDB_LEN 16
/*
* Ensure we have resources for ERP and initialization:
* 1 for ERP
* 1 for initialization
* 1 for each discovery thread
*/
#define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + disc_threads)
#define IBMVFC_MAD_SUCCESS 0x00
#define IBMVFC_MAD_NOT_SUPPORTED 0xF1
#define IBMVFC_MAD_FAILED 0xF7
#define IBMVFC_MAD_DRIVER_FAILED 0xEE
#define IBMVFC_MAD_CRQ_ERROR 0xEF
enum ibmvfc_crq_valid {
IBMVFC_CRQ_CMD_RSP = 0x80,
IBMVFC_CRQ_INIT_RSP = 0xC0,
IBMVFC_CRQ_XPORT_EVENT = 0xFF,
};
enum ibmvfc_crq_format {
IBMVFC_CRQ_INIT = 0x01,
IBMVFC_CRQ_INIT_COMPLETE = 0x02,
IBMVFC_PARTITION_MIGRATED = 0x06,
};
enum ibmvfc_cmd_status_flags {
IBMVFC_FABRIC_MAPPED = 0x0001,
IBMVFC_VIOS_FAILURE = 0x0002,
IBMVFC_FC_FAILURE = 0x0004,
IBMVFC_FC_SCSI_ERROR = 0x0008,
IBMVFC_HW_EVENT_LOGGED = 0x0010,
IBMVFC_VIOS_LOGGED = 0x0020,
};
enum ibmvfc_fabric_mapped_errors {
IBMVFC_UNABLE_TO_ESTABLISH = 0x0001,
IBMVFC_XPORT_FAULT = 0x0002,
IBMVFC_CMD_TIMEOUT = 0x0003,
IBMVFC_ENETDOWN = 0x0004,
IBMVFC_HW_FAILURE = 0x0005,
IBMVFC_LINK_DOWN_ERR = 0x0006,
IBMVFC_LINK_DEAD_ERR = 0x0007,
IBMVFC_UNABLE_TO_REGISTER = 0x0008,
IBMVFC_XPORT_BUSY = 0x000A,
IBMVFC_XPORT_DEAD = 0x000B,
IBMVFC_CONFIG_ERROR = 0x000C,
IBMVFC_NAME_SERVER_FAIL = 0x000D,
IBMVFC_LINK_HALTED = 0x000E,
IBMVFC_XPORT_GENERAL = 0x8000,
};
enum ibmvfc_vios_errors {
IBMVFC_CRQ_FAILURE = 0x0001,
IBMVFC_SW_FAILURE = 0x0002,
IBMVFC_INVALID_PARAMETER = 0x0003,
IBMVFC_MISSING_PARAMETER = 0x0004,
IBMVFC_HOST_IO_BUS = 0x0005,
IBMVFC_TRANS_CANCELLED = 0x0006,
IBMVFC_TRANS_CANCELLED_IMPLICIT = 0x0007,
IBMVFC_INSUFFICIENT_RESOURCE = 0x0008,
IBMVFC_PLOGI_REQUIRED = 0x0010,
IBMVFC_COMMAND_FAILED = 0x8000,
};
enum ibmvfc_mad_types {
IBMVFC_NPIV_LOGIN = 0x0001,
IBMVFC_DISC_TARGETS = 0x0002,
IBMVFC_PORT_LOGIN = 0x0004,
IBMVFC_PROCESS_LOGIN = 0x0008,
IBMVFC_QUERY_TARGET = 0x0010,
IBMVFC_IMPLICIT_LOGOUT = 0x0040,
IBMVFC_PASSTHRU = 0x0200,
IBMVFC_TMF_MAD = 0x0100,
};
struct ibmvfc_mad_common {
u32 version;
u32 reserved;
u32 opcode;
u16 status;
u16 length;
u64 tag;
}__attribute__((packed, aligned (8)));
struct ibmvfc_npiv_login_mad {
struct ibmvfc_mad_common common;
struct srp_direct_buf buffer;
}__attribute__((packed, aligned (8)));
#define IBMVFC_MAX_NAME 256
struct ibmvfc_npiv_login {
u32 ostype;
#define IBMVFC_OS_LINUX 0x02
u32 pad;
u64 max_dma_len;
u32 max_payload;
u32 max_response;
u32 partition_num;
u32 vfc_frame_version;
u16 fcp_version;
u16 flags;
#define IBMVFC_CLIENT_MIGRATED 0x01
#define IBMVFC_FLUSH_ON_HALT 0x02
u32 max_cmds;
u64 capabilities;
#define IBMVFC_CAN_MIGRATE 0x01
u64 node_name;
struct srp_direct_buf async;
u8 partition_name[IBMVFC_MAX_NAME];
u8 device_name[IBMVFC_MAX_NAME];
u8 drc_name[IBMVFC_MAX_NAME];
u64 reserved2[2];
}__attribute__((packed, aligned (8)));
struct ibmvfc_common_svc_parms {
u16 fcph_version;
u16 b2b_credit;
u16 features;
u16 bb_rcv_sz; /* upper nibble is BB_SC_N */
u32 ratov;
u32 edtov;
}__attribute__((packed, aligned (4)));
struct ibmvfc_service_parms {
struct ibmvfc_common_svc_parms common;
u8 port_name[8];
u8 node_name[8];
u32 class1_parms[4];
u32 class2_parms[4];
u32 class3_parms[4];
u32 obsolete[4];
u32 vendor_version[4];
u32 services_avail[2];
u32 ext_len;
u32 reserved[30];
u32 clk_sync_qos[2];
}__attribute__((packed, aligned (4)));
struct ibmvfc_npiv_login_resp {
u32 version;
u16 status;
u16 error;
u32 flags;
#define IBMVFC_NATIVE_FC 0x01
#define IBMVFC_CAN_FLUSH_ON_HALT 0x08
u32 reserved;
u64 capabilites;
u32 max_cmds;
u32 scsi_id_sz;
u64 max_dma_len;
u64 scsi_id;
u64 port_name;
u64 node_name;
u64 link_speed;
u8 partition_name[IBMVFC_MAX_NAME];
u8 device_name[IBMVFC_MAX_NAME];
u8 port_loc_code[IBMVFC_MAX_NAME];
u8 drc_name[IBMVFC_MAX_NAME];
struct ibmvfc_service_parms service_parms;
u64 reserved2;
}__attribute__((packed, aligned (8)));
union ibmvfc_npiv_login_data {
struct ibmvfc_npiv_login login;
struct ibmvfc_npiv_login_resp resp;
}__attribute__((packed, aligned (8)));
struct ibmvfc_discover_targets_buf {
u32 scsi_id[1];
#define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
};
struct ibmvfc_discover_targets {
struct ibmvfc_mad_common common;
struct srp_direct_buf buffer;
u32 flags;
u16 status;
u16 error;
u32 bufflen;
u32 num_avail;
u32 num_written;
u64 reserved[2];
}__attribute__((packed, aligned (8)));
enum ibmvfc_fc_reason {
IBMVFC_INVALID_ELS_CMD_CODE = 0x01,
IBMVFC_INVALID_VERSION = 0x02,
IBMVFC_LOGICAL_ERROR = 0x03,
IBMVFC_INVALID_CT_IU_SIZE = 0x04,
IBMVFC_LOGICAL_BUSY = 0x05,
IBMVFC_PROTOCOL_ERROR = 0x07,
IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09,
IBMVFC_CMD_NOT_SUPPORTED = 0x0B,
IBMVFC_SERVER_NOT_AVAIL = 0x0D,
IBMVFC_CMD_IN_PROGRESS = 0x0E,
IBMVFC_VENDOR_SPECIFIC = 0xFF,
};
enum ibmvfc_fc_type {
IBMVFC_FABRIC_REJECT = 0x01,
IBMVFC_PORT_REJECT = 0x02,
IBMVFC_LS_REJECT = 0x03,
IBMVFC_FABRIC_BUSY = 0x04,
IBMVFC_PORT_BUSY = 0x05,
IBMVFC_BASIC_REJECT = 0x06,
};
enum ibmvfc_gs_explain {
IBMVFC_PORT_NAME_NOT_REG = 0x02,
};
struct ibmvfc_port_login {
struct ibmvfc_mad_common common;
u64 scsi_id;
u16 reserved;
u16 fc_service_class;
u32 blksz;
u32 hdr_per_blk;
u16 status;
u16 error; /* also fc_reason */
u16 fc_explain;
u16 fc_type;
u32 reserved2;
struct ibmvfc_service_parms service_parms;
struct ibmvfc_service_parms service_parms_change;
u64 reserved3[2];
}__attribute__((packed, aligned (8)));
struct ibmvfc_prli_svc_parms {
u8 type;
#define IBMVFC_SCSI_FCP_TYPE 0x08
u8 type_ext;
u16 flags;
#define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
#define IBMVFC_PRLI_RESP_PA_VALID 0x4000
#define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
u32 orig_pa;
u32 resp_pa;
u32 service_parms;
#define IBMVFC_PRLI_TASK_RETRY 0x00000200
#define IBMVFC_PRLI_RETRY 0x00000100
#define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
#define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
#define IBMVFC_PRLI_TARGET_FUNC 0x00000010
#define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
#define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
}__attribute__((packed, aligned (4)));
struct ibmvfc_process_login {
struct ibmvfc_mad_common common;
u64 scsi_id;
struct ibmvfc_prli_svc_parms parms;
u8 reserved[48];
u16 status;
u16 error; /* also fc_reason */
u32 reserved2;
u64 reserved3[2];
}__attribute__((packed, aligned (8)));
struct ibmvfc_query_tgt {
struct ibmvfc_mad_common common;
u64 wwpn;
u64 scsi_id;
u16 status;
u16 error;
u16 fc_explain;
u16 fc_type;
u64 reserved[2];
}__attribute__((packed, aligned (8)));
struct ibmvfc_implicit_logout {
struct ibmvfc_mad_common common;
u64 old_scsi_id;
u64 reserved[2];
}__attribute__((packed, aligned (8)));
struct ibmvfc_tmf {
struct ibmvfc_mad_common common;
u64 scsi_id;
struct scsi_lun lun;
u32 flags;
#define IBMVFC_TMF_ABORT_TASK 0x02
#define IBMVFC_TMF_ABORT_TASK_SET 0x04
#define IBMVFC_TMF_LUN_RESET 0x10
#define IBMVFC_TMF_TGT_RESET 0x20
#define IBMVFC_TMF_LUA_VALID 0x40
u32 cancel_key;
u32 my_cancel_key;
u32 pad;
u64 reserved[2];
}__attribute__((packed, aligned (8)));
enum ibmvfc_fcp_rsp_info_codes {
RSP_NO_FAILURE = 0x00,
RSP_TMF_REJECTED = 0x04,
RSP_TMF_FAILED = 0x05,
RSP_TMF_INVALID_LUN = 0x09,
};
struct ibmvfc_fcp_rsp_info {
u16 reserved;
u8 rsp_code;
u8 reserved2[4];
}__attribute__((packed, aligned (2)));
enum ibmvfc_fcp_rsp_flags {
FCP_BIDI_RSP = 0x80,
FCP_BIDI_READ_RESID_UNDER = 0x40,
FCP_BIDI_READ_RESID_OVER = 0x20,
FCP_CONF_REQ = 0x10,
FCP_RESID_UNDER = 0x08,
FCP_RESID_OVER = 0x04,
FCP_SNS_LEN_VALID = 0x02,
FCP_RSP_LEN_VALID = 0x01,
};
union ibmvfc_fcp_rsp_data {
struct ibmvfc_fcp_rsp_info info;
u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)];
}__attribute__((packed, aligned (8)));
struct ibmvfc_fcp_rsp {
u64 reserved;
u16 retry_delay_timer;
u8 flags;
u8 scsi_status;
u32 fcp_resid;
u32 fcp_sense_len;
u32 fcp_rsp_len;
union ibmvfc_fcp_rsp_data data;
}__attribute__((packed, aligned (8)));
enum ibmvfc_cmd_flags {
IBMVFC_SCATTERLIST = 0x0001,
IBMVFC_NO_MEM_DESC = 0x0002,
IBMVFC_READ = 0x0004,
IBMVFC_WRITE = 0x0008,
IBMVFC_TMF = 0x0080,
IBMVFC_CLASS_3_ERR = 0x0100,
};
enum ibmvfc_fc_task_attr {
IBMVFC_SIMPLE_TASK = 0x00,
IBMVFC_HEAD_OF_QUEUE = 0x01,
IBMVFC_ORDERED_TASK = 0x02,
IBMVFC_ACA_TASK = 0x04,
};
enum ibmvfc_fc_tmf_flags {
IBMVFC_ABORT_TASK_SET = 0x02,
IBMVFC_LUN_RESET = 0x10,
IBMVFC_TARGET_RESET = 0x20,
};
struct ibmvfc_fcp_cmd_iu {
struct scsi_lun lun;
u8 crn;
u8 pri_task_attr;
u8 tmf_flags;
u8 add_cdb_len;
#define IBMVFC_RDDATA 0x02
#define IBMVFC_WRDATA 0x01
u8 cdb[IBMVFC_MAX_CDB_LEN];
u32 xfer_len;
}__attribute__((packed, aligned (4)));
struct ibmvfc_cmd {
u64 task_tag;
u32 frame_type;
u32 payload_len;
u32 resp_len;
u32 adapter_resid;
u16 status;
u16 error;
u16 flags;
u16 response_flags;
#define IBMVFC_ADAPTER_RESID_VALID 0x01
u32 cancel_key;
u32 exchange_id;
struct srp_direct_buf ext_func;
struct srp_direct_buf ioba;
struct srp_direct_buf resp;
u64 correlation;
u64 tgt_scsi_id;
u64 tag;
u64 reserved3[2];
struct ibmvfc_fcp_cmd_iu iu;
struct ibmvfc_fcp_rsp rsp;
}__attribute__((packed, aligned (8)));
struct ibmvfc_passthru_fc_iu {
u32 payload[7];
#define IBMVFC_ADISC 0x52000000
u32 response[7];
};
struct ibmvfc_passthru_iu {
u64 task_tag;
u32 cmd_len;
u32 rsp_len;
u16 status;
u16 error;
u32 flags;
#define IBMVFC_FC_ELS 0x01
u32 cancel_key;
u32 reserved;
struct srp_direct_buf cmd;
struct srp_direct_buf rsp;
u64 correlation;
u64 scsi_id;
u64 tag;
u64 reserved2[2];
}__attribute__((packed, aligned (8)));
struct ibmvfc_passthru_mad {
struct ibmvfc_mad_common common;
struct srp_direct_buf cmd_ioba;
struct ibmvfc_passthru_iu iu;
struct ibmvfc_passthru_fc_iu fc_iu;
}__attribute__((packed, aligned (8)));
struct ibmvfc_trace_start_entry {
u32 xfer_len;
}__attribute__((packed));
struct ibmvfc_trace_end_entry {
u16 status;
u16 error;
u8 fcp_rsp_flags;
u8 rsp_code;
u8 scsi_status;
u8 reserved;
}__attribute__((packed));
struct ibmvfc_trace_entry {
struct ibmvfc_event *evt;
u32 time;
u32 scsi_id;
u32 lun;
u8 fmt;
u8 op_code;
u8 tmf_flags;
u8 type;
#define IBMVFC_TRC_START 0x00
#define IBMVFC_TRC_END 0xff
union {
struct ibmvfc_trace_start_entry start;
struct ibmvfc_trace_end_entry end;
} u;
}__attribute__((packed, aligned (8)));
enum ibmvfc_crq_formats {
IBMVFC_CMD_FORMAT = 0x01,
IBMVFC_ASYNC_EVENT = 0x02,
IBMVFC_MAD_FORMAT = 0x04,
};
enum ibmvfc_async_event {
IBMVFC_AE_ELS_PLOGI = 0x0001,
IBMVFC_AE_ELS_LOGO = 0x0002,
IBMVFC_AE_ELS_PRLO = 0x0004,
IBMVFC_AE_SCN_NPORT = 0x0008,
IBMVFC_AE_SCN_GROUP = 0x0010,
IBMVFC_AE_SCN_DOMAIN = 0x0020,
IBMVFC_AE_SCN_FABRIC = 0x0040,
IBMVFC_AE_LINK_UP = 0x0080,
IBMVFC_AE_LINK_DOWN = 0x0100,
IBMVFC_AE_LINK_DEAD = 0x0200,
IBMVFC_AE_HALT = 0x0400,
IBMVFC_AE_RESUME = 0x0800,
IBMVFC_AE_ADAPTER_FAILED = 0x1000,
};
struct ibmvfc_crq {
volatile u8 valid;
volatile u8 format;
u8 reserved[6];
volatile u64 ioba;
}__attribute__((packed, aligned (8)));
struct ibmvfc_crq_queue {
struct ibmvfc_crq *msgs;
int size, cur;
dma_addr_t msg_token;
};
struct ibmvfc_async_crq {
volatile u8 valid;
u8 pad[3];
u32 pad2;
volatile u64 event;
volatile u64 scsi_id;
volatile u64 wwpn;
volatile u64 node_name;
u64 reserved;
}__attribute__((packed, aligned (8)));
struct ibmvfc_async_crq_queue {
struct ibmvfc_async_crq *msgs;
int size, cur;
dma_addr_t msg_token;
};
union ibmvfc_iu {
struct ibmvfc_mad_common mad_common;
struct ibmvfc_npiv_login_mad npiv_login;
struct ibmvfc_discover_targets discover_targets;
struct ibmvfc_port_login plogi;
struct ibmvfc_process_login prli;
struct ibmvfc_query_tgt query_tgt;
struct ibmvfc_implicit_logout implicit_logout;
struct ibmvfc_tmf tmf;
struct ibmvfc_cmd cmd;
struct ibmvfc_passthru_mad passthru;
}__attribute__((packed, aligned (8)));
enum ibmvfc_target_action {
IBMVFC_TGT_ACTION_NONE = 0,
IBMVFC_TGT_ACTION_INIT,
IBMVFC_TGT_ACTION_INIT_WAIT,
IBMVFC_TGT_ACTION_ADD_RPORT,
IBMVFC_TGT_ACTION_DEL_RPORT,
};
struct ibmvfc_target {
struct list_head queue;
struct ibmvfc_host *vhost;
u64 scsi_id;
u64 new_scsi_id;
struct fc_rport *rport;
int target_id;
enum ibmvfc_target_action action;
int need_login;
int init_retries;
struct ibmvfc_service_parms service_parms;
struct ibmvfc_service_parms service_parms_change;
struct fc_rport_identifiers ids;
void (*job_step) (struct ibmvfc_target *);
struct kref kref;
};
/* a unit of work for the hosting partition */
struct ibmvfc_event {
struct list_head queue;
struct ibmvfc_host *vhost;
struct ibmvfc_target *tgt;
struct scsi_cmnd *cmnd;
atomic_t free;
union ibmvfc_iu *xfer_iu;
void (*done) (struct ibmvfc_event *);
struct ibmvfc_crq crq;
union ibmvfc_iu iu;
union ibmvfc_iu *sync_iu;
struct srp_direct_buf *ext_list;
dma_addr_t ext_list_token;
struct completion comp;
struct completion *eh_comp;
struct timer_list timer;
};
/* a pool of event structs for use */
struct ibmvfc_event_pool {
struct ibmvfc_event *events;
u32 size;
union ibmvfc_iu *iu_storage;
dma_addr_t iu_token;
};
enum ibmvfc_host_action {
IBMVFC_HOST_ACTION_NONE = 0,
IBMVFC_HOST_ACTION_INIT,
IBMVFC_HOST_ACTION_INIT_WAIT,
IBMVFC_HOST_ACTION_QUERY,
IBMVFC_HOST_ACTION_QUERY_TGTS,
IBMVFC_HOST_ACTION_TGT_DEL,
IBMVFC_HOST_ACTION_ALLOC_TGTS,
IBMVFC_HOST_ACTION_TGT_INIT,
IBMVFC_HOST_ACTION_TGT_DEL_FAILED,
IBMVFC_HOST_ACTION_TGT_ADD,
};
enum ibmvfc_host_state {
IBMVFC_NO_CRQ = 0,
IBMVFC_INITIALIZING,
IBMVFC_ACTIVE,
IBMVFC_HALTED,
IBMVFC_LINK_DOWN,
IBMVFC_LINK_DEAD,
IBMVFC_HOST_OFFLINE,
};
struct ibmvfc_host {
char name[8];
struct list_head queue;
struct Scsi_Host *host;
enum ibmvfc_host_state state;
enum ibmvfc_host_action action;
#define IBMVFC_NUM_TRACE_INDEX_BITS 8
#define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
#define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
struct ibmvfc_trace_entry *trace;
u32 trace_index:IBMVFC_NUM_TRACE_INDEX_BITS;
int num_targets;
struct list_head targets;
struct list_head sent;
struct list_head free;
struct device *dev;
struct ibmvfc_event_pool pool;
struct dma_pool *sg_pool;
mempool_t *tgt_pool;
struct ibmvfc_crq_queue crq;
struct ibmvfc_async_crq_queue async_crq;
struct ibmvfc_npiv_login login_info;
union ibmvfc_npiv_login_data *login_buf;
dma_addr_t login_buf_dma;
int disc_buf_sz;
int log_level;
struct ibmvfc_discover_targets_buf *disc_buf;
int task_set;
int init_retries;
int discovery_threads;
int client_migrated;
int reinit;
int delay_init;
int events_to_log;
#define IBMVFC_AE_LINKUP 0x0001
#define IBMVFC_AE_LINKDOWN 0x0002
#define IBMVFC_AE_RSCN 0x0004
dma_addr_t disc_buf_dma;
unsigned int partition_number;
char partition_name[97];
void (*job_step) (struct ibmvfc_host *);
struct task_struct *work_thread;
wait_queue_head_t init_wait_q;
wait_queue_head_t work_wait_q;
};
#define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
#define tgt_dbg(t, fmt, ...) \
DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
#define tgt_info(t, fmt, ...) \
dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
#define tgt_err(t, fmt, ...) \
dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
#define ibmvfc_dbg(vhost, ...) \
DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
#define ibmvfc_log(vhost, level, ...) \
do { \
if ((vhost)->log_level >= level) \
dev_err((vhost)->dev, ##__VA_ARGS__); \
} while (0)
#define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
#define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
#ifdef CONFIG_SCSI_IBMVFC_TRACE
#define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
#define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
#else
#define ibmvfc_create_trace_file(kobj, attr) 0
#define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)
#endif
#endif
|
embest-tech/rowboat-kernel
|
drivers/scsi/ibmvscsi/ibmvfc.h
|
C
|
gpl-2.0
| 17,727 |
/*
* Copyright (c) 2011-2012, The Linux Foundation. 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.
*/
/*
* Qualcomm PMIC 8038 driver header file
*
*/
#ifndef __MFD_PM8038_H
#define __MFD_PM8038_H
#include <linux/device.h>
#include <linux/mfd/pm8xxx/irq.h>
#include <linux/mfd/pm8xxx/gpio.h>
#include <linux/mfd/pm8xxx/mpp.h>
#include <linux/mfd/pm8xxx/pwm.h>
#include <linux/mfd/pm8xxx/rtc.h>
#include <linux/input/pmic8xxx-pwrkey.h>
#include <linux/mfd/pm8xxx/misc.h>
#include <linux/regulator/pm8xxx-regulator.h>
#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
#include <linux/mfd/pm8xxx/pm8921-charger.h>
#include <linux/mfd/pm8xxx/pm8921-bms.h>
#include <linux/leds-pm8xxx.h>
#include <linux/mfd/pm8xxx/ccadc.h>
#include <linux/mfd/pm8xxx/spk.h>
#include <linux/mfd/pm8xxx/tm.h>
#include <linux/mfd/pm8xxx/vibrator.h>
#define PM8038_CORE_DEV_NAME "pm8038-core"
#define PM8038_NR_IRQS 256
#define PM8038_NR_GPIOS 12
#define PM8038_NR_MPPS 6
#define PM8038_GPIO_BLOCK_START 24
#define PM8038_MPP_BLOCK_START 16
#define PM8038_IRQ_BLOCK_BIT(block, bit) ((block) * 8 + (bit))
/* GPIO and MPPs [1,N] */
#define PM8038_GPIO_IRQ(base, gpio) ((base) + \
PM8038_IRQ_BLOCK_BIT(PM8038_GPIO_BLOCK_START, (gpio)-1))
#define PM8038_MPP_IRQ(base, mpp) ((base) + \
PM8038_IRQ_BLOCK_BIT(PM8038_MPP_BLOCK_START, (mpp)-1))
/* PMIC Interrupts */
#define PM8038_RTC_ALARM_IRQ PM8038_IRQ_BLOCK_BIT(4, 7)
#define PM8038_BATT_ALARM_IRQ PM8921_IRQ_BLOCK_BIT(5, 6)
#define PM8038_PWRKEY_REL_IRQ PM8038_IRQ_BLOCK_BIT(6, 2)
#define PM8038_PWRKEY_PRESS_IRQ PM8038_IRQ_BLOCK_BIT(6, 3)
#define PM8038_KEYPAD_IRQ PM8038_IRQ_BLOCK_BIT(9, 2)
#define PM8038_KEYSTUCK_IRQ PM8038_IRQ_BLOCK_BIT(9, 3)
#define PM8038_ADC_EOC_USR_IRQ PM8038_IRQ_BLOCK_BIT(9, 6)
#define PM8038_ADC_BATT_TEMP_WARM_IRQ PM8038_IRQ_BLOCK_BIT(9, 1)
#define PM8038_ADC_BATT_TEMP_COLD_IRQ PM8038_IRQ_BLOCK_BIT(9, 0)
#define PM8038_USB_ID_IN_IRQ(base) (base + PM8921_IRQ_BLOCK_BIT(6, 1))
#define PM8038_RESOUT_IRQ PM8038_IRQ_BLOCK_BIT(6, 4)
#define PM8038_OVERTEMP_IRQ PM8038_IRQ_BLOCK_BIT(4, 2)
#define PM8038_TEMPSTAT_IRQ PM8038_IRQ_BLOCK_BIT(6, 7)
struct pm8038_platform_data {
int irq_base;
struct pm8xxx_gpio_platform_data *gpio_pdata;
struct pm8xxx_irq_platform_data *irq_pdata;
struct pm8xxx_mpp_platform_data *mpp_pdata;
struct pm8xxx_rtc_platform_data *rtc_pdata;
struct pm8xxx_pwrkey_platform_data *pwrkey_pdata;
struct pm8xxx_misc_platform_data *misc_pdata;
struct pm8xxx_regulator_platform_data *regulator_pdatas;
int num_regulators;
struct pm8921_charger_platform_data *charger_pdata;
struct pm8921_bms_platform_data *bms_pdata;
struct pm8xxx_adc_platform_data *adc_pdata;
struct pm8xxx_led_platform_data *leds_pdata;
struct pm8xxx_vibrator_platform_data *vibrator_pdata;
struct pm8xxx_ccadc_platform_data *ccadc_pdata;
struct pm8xxx_spk_platform_data *spk_pdata;
/* */
#if 0 // def CONFIG_PMIC8XXX_VIBRATOR
struct pm8xxx_vibrator_platform_data *vibrator_pdata;
#endif
#ifdef CONFIG_LGE_DIRECT_QCOIN_VIBRATOR
struct direct_qcoin_platform_data *pm8xxx_qcoin_pdata;
#endif
};
#endif
|
Volidol1/android_kernel_lge_d605
|
include/linux/mfd/pm8xxx/pm8038.h
|
C
|
gpl-2.0
| 3,587 |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="听风行" />
<title>听风行</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="听风行,听风行博客,IT技术分享,TingBrowser,TensorFlow,树莓派,Linux,RaspberryPi" />
<meta name="description" content="虽千万人吾往矣">
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/av-min.js" async></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
<script src="//unpkg.com/valine/dist/Valine.min.js" async></script>
<script>
// theme-ad's config script
// it can be used in every script
window.AD_CONFIG = {
leancloud: {"appid":"JUB4uWwzKVKwbNzwRvkxgw9F-gzGzoHsz","appkey":"tLtzj0dg7LQTGu9dEY57RYef","comment":true,"count":true},
welcome: {"enable":true,"interval":30},
start_time: "2015-07-01",
passwords: [],
is_post: false,
lock: false,
author: "听风行",
share: {"twitter":true,"facebook":true,"weibo":true,"qq":true,"wechat":true},
mathjax: true,
page_type: "",
root: "/"
};
</script>
<script src="/vendor/sha256.min.js"></script>
<script src="/js/auth.js"></script>
<script src="/js/index.js"></script>
<script src="/vendor/qrcode.min.js"></script>
<link rel="icon" href="/images/favicon.ico">
<link rel="apple-touch-icon" href="/images/favicon.ico">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/styles/components/highlight/highlight.css">
<meta name="generator" content="Hexo 5.2.0"></head>
<body>
<header class="site-header">
<div class="site-header-brand">
<span class="site-header-brand-title">
<a href="/">听风行</a>
</span>
<span class="site-header-brand-motto"> | 虽千万人吾往矣</span>
</div>
<div class="site-header-right">
<nav class="site-header-navigation">
<a href="/" target="_self">首页</a>
<a href="/archives/" target="_self">归档</a>
<a href="/tags/" target="_self">标签</a>
<a href="/categories/" target="_self">分类</a>
<a href="/friends/" target="_self">友链</a>
<a href="/about/" target="_self">关于</a>
</nav>
<div class="site-header-btn">
<a href="https://github.com/yuolvv/" target="_blank" id="site-github">
<i class="fa fa-github-alt"></i>
</a>
<a href="javascript:void(0);" id="site-search">
<i class="fa fa-search"></i>
</a>
<a href="javascript:void(0);" id="site-nav-btn">
<i class="fa fa-ellipsis-v"></i>
</a>
</div>
</div>
</header>
<nav class="table-content" id="site-nav">
<div class="table-content-title">
<span>导航</span>
</div>
<div class="table-content-main">
<ol class="toc">
<li class="toc-item">
<a href="/" target="_self">
首页
</a>
</li>
<li class="toc-item">
<a href="/archives/" target="_self">
归档
</a>
</li>
<li class="toc-item">
<a href="/tags/" target="_self">
标签
</a>
</li>
<li class="toc-item">
<a href="/categories/" target="_self">
分类
</a>
</li>
<li class="toc-item">
<a href="/friends/" target="_self">
友链
</a>
</li>
<li class="toc-item">
<a href="/about/" target="_self">
关于
</a>
</li>
</ol>
</div>
</nav>
<div id="site-process"></div>
<main>
<div class="home">
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-24
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-24-SpringBoot-Source-10/">SpringBoot源码分析(10)-SpringBoot的内置生命周期事件</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringBoot的内置生命周期事件</p>
</div>
<a class="home-article-read" href="/posts/2020-11-24-SpringBoot-Source-10/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.NaturesWindowLookout_ZH-CN1799883608_1920x1080.jpg">
</div>
</div>
</div>
<!-- -->
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-23
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-23-SpringBoot-Source-09/">SpringBoot源码分析(9)-SpringBoot的事件监听机制</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringBoot的事件监听机制</p>
</div>
<a class="home-article-read" href="/posts/2020-11-23-SpringBoot-Source-09/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.ChipmunkJP_ZH-CN1697070440_1920x1080.jpg">
</div>
</div>
</div>
<!--
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-format="fluid"
data-ad-layout-key="-bf-6q-8m+nf+1bo"
data-ad-client="ca-pub-2795125801721613"
data-ad-slot="6334319385"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
-->
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-22
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-22-SpringBoot-Source-08/">SpringBoot源码分析(8)-SpringApplication对象的构建过程</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringApplication对象的构建过程</p>
</div>
<a class="home-article-read" href="/posts/2020-11-22-SpringBoot-Source-08/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.CPMall_ZH-CN1202155438_1920x1080.jpg">
</div>
</div>
</div>
<!-- -->
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-21
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-21-SpringBoot-Source-07/">SpringBoot源码分析(7)-SpringBoot的启动流程</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringBoot的启动流程</p>
</div>
<a class="home-article-read" href="/posts/2020-11-21-SpringBoot-Source-07/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.PorcupineBay_ZH-CN2252758146_1920x1080.jpg">
</div>
</div>
</div>
<!-- -->
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-20
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-20-SpringBoot-Source-06/">SpringBoot源码分析(6)-SpringBoot内置的Starter构建原理</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringBoot内置的Starter构建原理</p>
</div>
<a class="home-article-read" href="/posts/2020-11-20-SpringBoot-Source-06/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.AsilomarSB_ZH-CN1074865975_1920x1080.jpg">
</div>
</div>
</div>
<!-- -->
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-19
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-19-SpringBoot-Source-05/">SpringBoot源码分析(5)-SpringBoot 的配置属性值的绑定流程</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringBoot 的配置属性值的绑定流程</p>
</div>
<a class="home-article-read" href="/posts/2020-11-19-SpringBoot-Source-05/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.PineGrosbeak_ROW0658237649_1920x1080.jpg">
</div>
</div>
</div>
<!--
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-format="fluid"
data-ad-layout-key="-bf-6q-8m+nf+1bo"
data-ad-client="ca-pub-2795125801721613"
data-ad-slot="6334319385"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
-->
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-18
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-18-SpringBoot-Source-04/">SpringBoot源码分析(4)-SpringBoot 的自动配置</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringBoot 的自动配置</p>
</div>
<a class="home-article-read" href="/posts/2020-11-18-SpringBoot-Source-04/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.HocesDuraton_ZH-CN2152159552_1920x1080.jpg">
</div>
</div>
</div>
<!-- -->
<div class="home-article-wrapper clearfix">
<div class="home-article" data-cover="true">
<div class="home-article-inner" data-cover="true">
<div class="passage-meta">
<span>
<i class="fa fa-calendar"></i>2020-11-17
</span>
<span>
| <a href="/categories/Java/"><i class="fa fa-bookmark"></i>Java</a>
</span>
<span>
| <i class="fa fa-unlock-alt"></i>Unlock
</span>
</div>
<h1 class="home-article-title">
<a href="/posts/2020-11-17-SpringBoot-Source-03/">SpringBoot源码分析(3)-SpringBoot自动配置的条件注解原理</a>
</h1>
<div class="home-article-content passage-article">
<p>   记录SpringBoot的源码分析过程-SpringBoot自动配置的条件注解原理</p>
</div>
<a class="home-article-read" href="/posts/2020-11-17-SpringBoot-Source-03/">
Read More >>>
</a>
<div class="passage-tags">
<a href="/tags/Java/"><i class="fa fa-tags"></i>Java</a>
<a href="/tags/SpringBoot/"><i class="fa fa-tags"></i>SpringBoot</a>
<a href="/tags/Source/"><i class="fa fa-tags"></i>Source</a>
</div>
</div>
<div class="home-article-cover">
<img src="https://cn.bing.com/th?id=OHR.ValCervara_ZH-CN1889046979_1920x1080.jpg">
</div>
</div>
</div>
<!-- -->
</div>
</main>
<div class="site-footer-wrapper">
<footer class="site-footer">
<div class="site-footer-col">
<h5 class="site-footer-title">友链推荐</h5>
<span class="site-footer-item">
<a href="https://www.iyu.pub" target="_blank">听风行官网</a>
</span>
<span class="site-footer-item">
<a href="https://browser.iyu.pub" target="_blank">TingBrowser</a>
</span>
<span class="site-footer-item">
<a href="https://www.zhyui.com" target="_blank">Timogal</a>
</span>
<span class="site-footer-item">
<a href="http://www.sqliu.cn" target="_blank">桥帮主</a>
</span>
</div>
<div class="site-footer-col">
<h5 class="site-footer-title">服务器推荐</h5>
<span class="site-footer-item">
<a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=5e3lfzbh" target="_blank">阿里云服务器</a>
</span>
<span class="site-footer-item">
<a href="https://cloud.tencent.com/redirect.php?redirect=1001&cps_key=4a5ddee5a29f458f6de46e4f27bc904e&from=console" target="_blank">腾讯云服务器</a>
</span>
<span class="site-footer-item">
<a href="https://cloud.baidu.com/campaign/partner/index.html?teamCode=GC6E98UL" target="_blank">百度云服务器</a>
</span>
</div>
<div class="site-footer-col">
<h5 class="site-footer-title">社交の平台</h5>
<span class="site-footer-item">
<a href="https://twitter.com/tingfengxing" target="_blank">Twitter</a>
</span>
<span class="site-footer-item">
<a href="https://www.facebook.com/tingfengxing" target="_blank">Facebook</a>
</span>
</div>
<div class="site-footer-info">
<i class="fa fa-clock-o"></i> 本站已稳定运行<span id="site-time"></span>
</div>
<div class="site-footer-info">
<i class="fa fa-paw"></i> 您是本站第 <span id="site-count"></span> 位访客
</div>
<div class="site-footer-info">
<i class="fa fa-at"></i> <a href="mailto:Email: [email protected]">Email: [email protected]
</div>
<div class="site-footer-info">
<i class="fa fa-copyright"></i>
2015~2020 <a href="https://blog.iyu.pub" target="_blank">https://blog.iyu.pub</a>.
Created by <a href="https://177.im/" target="_blank">听风行</a>.
All rights reserved.
</div>
</footer>
</div>
<div id="site-layer" style="display:none;">
<div class="site-layer-content">
<div class="site-layer-header">
<span class="site-layer-header-title" id="site-layer-title"></span>
<i class="fa fa-close" id="site-layer-close"></i>
</div>
<div class="site-layer-body" id="site-layer-container">
<div class="site-layer-input" id="site-layer-search" style="display: none;">
<div class="site-layer-input-choose">
<a href="javascript:void(0);" title="Change Search Engine">Google</a>
</div>
<input type="text">
<i class="fa fa-search"></i>
</div>
<div class="site-layer-reward" id="site-layer-reward" style="display: none;">
<div>
<img src="/images/wechat.png" alt="WeChat">
<p>WeChat</p>
</div>
<div>
<img src="/images/alipay.png" alt="AliPay">
<p>AliPay</p>
</div>
</div>
<div id="site-layer-welcome" style="display:none;"></div>
</div>
</div>
</div>
<div class="bottom-bar">
<div class="bottom-bar-left">
<a href="javascript:void(0);" data-enable="false">
<i class="fa fa-arrow-left"></i>
</a>
<a href="/page/2/" data-enable="true">
<i class="fa fa-arrow-right"></i>
</a>
</div>
<div class="bottom-bar-right">
<a href="javascript:void(0);" data-enable="false" id="site-toc-show-btn">
<i class="fa fa-bars"></i>
</a>
<a href="javascript:void(0);" data-enable="false">
<i class="fa fa-commenting"></i>
</a>
<a href="javascript:void(0);" id="site-toggle-share-btn">
<i class="fa fa-share-alt"></i>
</a>
<a href="javascript:void(0);" id="site-reward">
<i class="fa fa-thumbs-up"></i>
</a>
<a href="javascript:void(0);" id="back-top-btn">
<i class="fa fa-chevron-up"></i>
</a>
</div>
</div>
<div id="share-btn">
<a id="share-btn-twitter" href="javascript:void(0);" target="_blank">
<i class="fa fa-twitter"></i>
</a>
<a id="share-btn-facebook" href="javascript:void(0);" target="_blank">
<i class="fa fa-facebook"></i>
</a>
<a id="share-btn-weibo" href="javascript:void(0);" target="_blank">
<i class="fa fa-weibo"></i>
</a>
<a id="share-btn-qq" href="javascript:void(0);" target="_blank">
<i class="fa fa-qq"></i>
</a>
<a id="share-btn-wechat" href="javascript:void(0);" target="_blank">
<i class="fa fa-wechat"></i>
</a>
</div>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-88629664-2"></script>
<script async>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-88629664-2');
</script>
<script async>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "2133ab6ff866479db3e4979524888b83"}'></script>
</body>
</html>
|
yuolvv/yuolvv.github.io
|
index.html
|
HTML
|
gpl-2.0
| 25,050 |
/*
* linux/drivers/video/savage/savagefb-i2c.c - S3 Savage DDC2
*
* Copyright 2004 Antonino A. Daplas <adaplas @pol.net>
*
* Based partly on rivafb-i2c.c
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/fb.h>
#include <asm/io.h>
#include "savagefb.h"
#define SAVAGE_DDC 0x50
#define VGA_CR_IX 0x3d4
#define VGA_CR_DATA 0x3d5
#define CR_SERIAL1 0xa0 /* I2C serial communications interface */
#define MM_SERIAL1 0xff20
#define CR_SERIAL2 0xb1 /* DDC2 monitor communications interface */
/* based on vt8365 documentation */
#define PROSAVAGE_I2C_ENAB 0x10
#define PROSAVAGE_I2C_SCL_OUT 0x01
#define PROSAVAGE_I2C_SDA_OUT 0x02
#define PROSAVAGE_I2C_SCL_IN 0x04
#define PROSAVAGE_I2C_SDA_IN 0x08
#define SAVAGE4_I2C_ENAB 0x00000020
#define SAVAGE4_I2C_SCL_OUT 0x00000001
#define SAVAGE4_I2C_SDA_OUT 0x00000002
#define SAVAGE4_I2C_SCL_IN 0x00000008
#define SAVAGE4_I2C_SDA_IN 0x00000010
#define SET_CR_IX(base, val) writeb((val), base + 0x8000 + VGA_CR_IX)
#define SET_CR_DATA(base, val) writeb((val), base + 0x8000 + VGA_CR_DATA)
#define GET_CR_DATA(base) readb(base + 0x8000 + VGA_CR_DATA)
static void savage4_gpio_setscl(void *data, int val)
{
struct savagefb_i2c_chan *chan = data;
unsigned int r;
r = readl(chan->ioaddr + chan->reg);
if(val)
r |= SAVAGE4_I2C_SCL_OUT;
else
r &= ~SAVAGE4_I2C_SCL_OUT;
writel(r, chan->ioaddr + chan->reg);
readl(chan->ioaddr + chan->reg); /* flush posted write */
}
static void savage4_gpio_setsda(void *data, int val)
{
struct savagefb_i2c_chan *chan = data;
unsigned int r;
r = readl(chan->ioaddr + chan->reg);
if(val)
r |= SAVAGE4_I2C_SDA_OUT;
else
r &= ~SAVAGE4_I2C_SDA_OUT;
writel(r, chan->ioaddr + chan->reg);
readl(chan->ioaddr + chan->reg); /* flush posted write */
}
static int savage4_gpio_getscl(void *data)
{
struct savagefb_i2c_chan *chan = data;
return (0 != (readl(chan->ioaddr + chan->reg) & SAVAGE4_I2C_SCL_IN));
}
static int savage4_gpio_getsda(void *data)
{
struct savagefb_i2c_chan *chan = data;
return (0 != (readl(chan->ioaddr + chan->reg) & SAVAGE4_I2C_SDA_IN));
}
static void prosavage_gpio_setscl(void* data, int val)
{
struct savagefb_i2c_chan *chan = data;
u32 r;
SET_CR_IX(chan->ioaddr, chan->reg);
r = GET_CR_DATA(chan->ioaddr);
r |= PROSAVAGE_I2C_ENAB;
if (val) {
r |= PROSAVAGE_I2C_SCL_OUT;
} else {
r &= ~PROSAVAGE_I2C_SCL_OUT;
}
SET_CR_DATA(chan->ioaddr, r);
}
static void prosavage_gpio_setsda(void* data, int val)
{
struct savagefb_i2c_chan *chan = data;
unsigned int r;
SET_CR_IX(chan->ioaddr, chan->reg);
r = GET_CR_DATA(chan->ioaddr);
r |= PROSAVAGE_I2C_ENAB;
if (val) {
r |= PROSAVAGE_I2C_SDA_OUT;
} else {
r &= ~PROSAVAGE_I2C_SDA_OUT;
}
SET_CR_DATA(chan->ioaddr, r);
}
static int prosavage_gpio_getscl(void* data)
{
struct savagefb_i2c_chan *chan = data;
SET_CR_IX(chan->ioaddr, chan->reg);
return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SCL_IN));
}
static int prosavage_gpio_getsda(void* data)
{
struct savagefb_i2c_chan *chan = data;
SET_CR_IX(chan->ioaddr, chan->reg);
return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN));
}
static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
const char *name)
{
int rc = 0;
if (chan->par) {
strcpy(chan->adapter.name, name);
chan->adapter.owner = THIS_MODULE;
chan->adapter.id = I2C_HW_B_SAVAGE;
chan->adapter.algo_data = &chan->algo;
chan->adapter.dev.parent = &chan->par->pcidev->dev;
chan->algo.udelay = 40;
chan->algo.mdelay = 5;
chan->algo.timeout = 20;
chan->algo.data = chan;
i2c_set_adapdata(&chan->adapter, chan);
/* Raise SCL and SDA */
chan->algo.setsda(chan, 1);
chan->algo.setscl(chan, 1);
udelay(20);
rc = i2c_bit_add_bus(&chan->adapter);
if (rc == 0)
dev_dbg(&chan->par->pcidev->dev,
"I2C bus %s registered.\n", name);
else
dev_warn(&chan->par->pcidev->dev,
"Failed to register I2C bus %s.\n", name);
} else
chan->par = NULL;
return rc;
}
void savagefb_create_i2c_busses(struct fb_info *info)
{
struct savagefb_par *par = info->par;
par->chan.par = par;
switch(info->fix.accel) {
case FB_ACCEL_PROSAVAGE_DDRK:
case FB_ACCEL_PROSAVAGE_PM:
par->chan.reg = CR_SERIAL2;
par->chan.ioaddr = par->mmio.vbase;
par->chan.algo.setsda = prosavage_gpio_setsda;
par->chan.algo.setscl = prosavage_gpio_setscl;
par->chan.algo.getsda = prosavage_gpio_getsda;
par->chan.algo.getscl = prosavage_gpio_getscl;
break;
case FB_ACCEL_SAVAGE4:
case FB_ACCEL_SAVAGE2000:
par->chan.reg = 0xff20;
par->chan.ioaddr = par->mmio.vbase;
par->chan.algo.setsda = savage4_gpio_setsda;
par->chan.algo.setscl = savage4_gpio_setscl;
par->chan.algo.getsda = savage4_gpio_getsda;
par->chan.algo.getscl = savage4_gpio_getscl;
break;
default:
par->chan.par = NULL;
}
savage_setup_i2c_bus(&par->chan, "SAVAGE DDC2");
}
void savagefb_delete_i2c_busses(struct fb_info *info)
{
struct savagefb_par *par = info->par;
if (par->chan.par)
i2c_bit_del_bus(&par->chan.adapter);
par->chan.par = NULL;
}
static u8 *savage_do_probe_i2c_edid(struct savagefb_i2c_chan *chan)
{
u8 start = 0x0;
struct i2c_msg msgs[] = {
{
.addr = SAVAGE_DDC,
.len = 1,
.buf = &start,
}, {
.addr = SAVAGE_DDC,
.flags = I2C_M_RD,
.len = EDID_LENGTH,
},
};
u8 *buf = NULL;
if (chan->par) {
buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
if (buf) {
msgs[1].buf = buf;
if (i2c_transfer(&chan->adapter, msgs, 2) != 2) {
dev_dbg(&chan->par->pcidev->dev,
"Unable to read EDID block.\n");
kfree(buf);
buf = NULL;
}
}
}
return buf;
}
int savagefb_probe_i2c_connector(struct fb_info *info, u8 **out_edid)
{
struct savagefb_par *par = info->par;
u8 *edid = NULL;
int i;
for (i = 0; i < 3; i++) {
/* Do the real work */
edid = savage_do_probe_i2c_edid(&par->chan);
if (edid)
break;
}
if (!edid) {
/* try to get from firmware */
const u8 *e = fb_firmware_edid(info->device);
if (e) {
edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
if (edid)
memcpy(edid, e, EDID_LENGTH);
}
}
*out_edid = edid;
return (edid) ? 0 : 1;
}
MODULE_LICENSE("GPL");
|
zrafa/linuxkernel
|
linux-2.6.17.new/drivers/video/savage/savagefb-i2c.c
|
C
|
gpl-2.0
| 6,459 |
var searchData=
[
['brightness',['brightness',['../interface_a_f_d_x_face_quality.html#a6bc58fe9b8f68f8720745ce03aab6448',1,'AFDXFaceQuality']]],
['browfurrow',['browFurrow',['../interface_a_f_d_x_expressions.html#ace8055c0c67815036d8ef8255cec23ff',1,'AFDXExpressions::browFurrow()'],['../interface_a_f_d_x_detector.html#a357b1fb5c30e7391c9e62b05821f0bfb',1,'AFDXDetector::browFurrow()']]],
['browraise',['browRaise',['../interface_a_f_d_x_expressions.html#a094ac554d1647ad9cfd31118e3b49a8b',1,'AFDXExpressions::browRaise()'],['../interface_a_f_d_x_detector.html#a0b6cf71d6fbda2e85f6aee5ed2989631',1,'AFDXDetector::browRaise()']]]
];
|
Affectiva/developerportal
|
pages/platforms/v4_0_0/ios/classdocs/search/properties_1.js
|
JavaScript
|
gpl-2.0
| 640 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_06) on Wed Dec 28 15:03:49 CET 2005 -->
<TITLE>
All Classes
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<FONT size="+1" CLASS="FrameHeadingFont">
<B>All Classes</B></FONT>
<BR>
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="jmatlink/testsuite/AllTests.html" title="class in jmatlink.testsuite">AllTests</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/AllTests.html" title="class in jmatlink.testsuite.jmatlink">AllTests</A>
<BR>
<A HREF="jmatlink/testsuite/Benchmark01.html" title="class in jmatlink.testsuite">Benchmark01</A>
<BR>
<A HREF="jmatlink/CoreJMatLink.html" title="class in jmatlink">CoreJMatLink</A>
<BR>
<A HREF="jmatlink/testsuite/EnduranceTest01.html" title="class in jmatlink.testsuite">EnduranceTest01</A>
<BR>
<A HREF="jmatlink/JMatLink.html" title="class in jmatlink">JMatLink</A>
<BR>
<A HREF="jmatlink/JMatLinkException.html" title="class in jmatlink">JMatLinkException</A>
<BR>
<A HREF="jmatlink/ui/SimpleTestGui.html" title="class in jmatlink.ui">SimpleTestGui</A>
<BR>
<A HREF="jmatlink/ui/SimpleTestGui02.html" title="class in jmatlink.ui">SimpleTestGui02</A>
<BR>
<A HREF="jmatlink/ui/SimpleTextGUI01.html" title="class in jmatlink.ui">SimpleTextGUI01</A>
<BR>
<A HREF="jmatlink/ui/SimpleTextGUI02.html" title="class in jmatlink.ui">SimpleTextGUI02</A>
<BR>
<A HREF="jmatlink/testsuite/StressTest01.html" title="class in jmatlink.testsuite">StressTest01</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testCoreJMatLink.html" title="class in jmatlink.testsuite.jmatlink">testCoreJMatLink</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngClose.html" title="class in jmatlink.testsuite.jmatlink">testEngClose</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngEvalString.html" title="class in jmatlink.testsuite.jmatlink">testEngEvalString</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngGetArray.html" title="class in jmatlink.testsuite.jmatlink">testEngGetArray</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngGetCharArray.html" title="class in jmatlink.testsuite.jmatlink">testEngGetCharArray</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngGetFigure.html" title="class in jmatlink.testsuite.jmatlink">testEngGetFigure</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngOpen.html" title="class in jmatlink.testsuite.jmatlink">testEngOpen</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngOutputBuffer.html" title="class in jmatlink.testsuite.jmatlink">testEngOutputBuffer</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngPutArray.html" title="class in jmatlink.testsuite.jmatlink">testEngPutArray</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testEngineThread.html" title="class in jmatlink.testsuite.jmatlink">testEngineThread</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testJMatLink.html" title="class in jmatlink.testsuite.jmatlink">testJMatLink</A>
<BR>
<A HREF="jmatlink/testsuite/jmatlink/testSingleUse.html" title="class in jmatlink.testsuite.jmatlink">testSingleUse</A>
<BR>
</FONT></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|
Olshansk/PLSNPAIRS-Thesis
|
extern/jMatLink/doc/javadoc/allclasses-noframe.html
|
HTML
|
gpl-2.0
| 3,356 |
#include "Primitives3d.h"
Primitive3d::Primitive3d(const Point3f & center, float x, float y, float z, SDL_Color color)
: Primitive3d(center, x, y, z, color, 0) {}
Primitive3d::Primitive3d(const Point3f & center, float x, float y, float z, GLuint textureID)
: Primitive3d(center, x, y, z, SDL_COLOR_GRAY, textureID) {}
Primitive3d::Primitive3d(const Point3f &_center, float _x, float _y, float _z, SDL_Color color, GLuint _textureID)
: PhysicsObject(_center, _x, _y, _z), textureID(_textureID), transformer(_center), color(toSDLColorf(color)), originalColor(toSDLColorf(color)),
ambientLightColor(toSDLColorf(SDL_COLOR_WHITE)), ambientLightIntensity(1.0f) {
shaderProgram = ShaderManager::getInstance()->createProgram(vertexShaderCode, fragmentShaderCode);
//shaderProgram = ShaderManager::getInstance()->createProgram(vertexShaderCodeSKY, fragmentShaderCodeSKY);
glUseProgram(shaderProgram); // TODO: check if needed here
mvpLocation = glGetUniformLocation(shaderProgram, "mvp");
colorLocation = glGetUniformLocation(shaderProgram, "color");
textureIDLocation = glGetUniformLocation(shaderProgram, "sampler");
useTextureLocation = glGetUniformLocation(shaderProgram, "useTexture");
lightColorLocation = glGetUniformLocation(shaderProgram, "light.color");
lightIntensityLocation = glGetUniformLocation(shaderProgram, "light.ambientIntensity");
useUI = glGetUniformLocation(shaderProgram, "useUI");
glUseProgram(0);
}
GLuint Primitive3d::createBuffer(GLenum bufferType, const void *bufferData, GLsizei bufferSize) {
GLuint buffer;
glGenBuffers(1, &buffer);
glBindBuffer(bufferType, buffer);
glBufferData(bufferType, bufferSize, bufferData, GL_STATIC_DRAW);
glBindBuffer(bufferType, 0); // unbind
return buffer;
}
void Primitive3d::setColor(SDL_Color _color) {
color = toSDLColorf(_color);
}
void Primitive3d::resetColor() {
color = originalColor;
}
void Primitive3d::setTexture(GLuint texture) {
textureID = texture;
}
// TODO: since object size is now different we need to adapt phys obj to it
void Primitive3d::scale(float x, float y, float z) {
transformer.scale += Vector3f(x, y, z);
}
void Primitive3d::setScale(float x, float y, float z) {
transformer.scale = Vector3f(x, y, z);
}
Vector3f Primitive3d::getScale() {
return transformer.scale;
}
void Primitive3d::rotate(float x, float y, float z) {
transformer.rotate += Vector3f(x, y, z);
}
void Primitive3d::setRotate(float x, float y, float z) {
transformer.rotate = Vector3f(x, y, z);
}
void Primitive3d::setCenter(float x, float y, float z) {
center = Point3f(x, y, z);
transformer.center = Vector3f(x, y, z);
}
void Primitive3d::setCenter(const Point3f & _center) {
setCenter(_center.x, _center.y, _center.z);
}
void Primitive3d::updateCameraTransforms() {
transformer.center = Vector3f(center.x, center.y, center.z);
}
void Primitive3d::move(const Vector3f & v) {
center += v;
transformer.center = Vector3f(center.x, center.y, center.z);
}
void Primitive3d::moveWithPhysics(const Vector3f & v) {
applyForce(v); // this might change center of the object
transformer.center = Vector3f(center.x, center.y, center.z);
}
void Primitive3d::applyGravity(const PhysicsEngine & engine) {
PhysicsObject::applyGravity(engine);
transformer.center = Vector3f(center.x, center.y, center.z);
}
void Primitive3d::applyAntiGravity(const PhysicsEngine & engine) {
PhysicsObject::applyAntiGravity(engine);
transformer.center = Vector3f(center.x, center.y, center.z);
}
Point3f Primitive3d::getCenter() {
return PhysicsObject::getCenter();
}
/* CUBOID CLASS DEFINITION */
Cuboid::Cuboid(const Point3f & center, float x, float y, float z, SDL_Color color)
: Cuboid(center, x, y, z, color, 0) {}
Cuboid::Cuboid(const Point3f & center, float x, float y, float z, GLuint textureID)
: Cuboid(center, x, y, z, SDL_COLOR_GRAY, textureID) {}
Cuboid::Cuboid(const Point3f & center, float lX, float lY, float lZ, SDL_Color color, GLuint textureID)
: Primitive3d(center, lX, lY, lZ, color, textureID) {
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
GLfloat vertexData[] = {
// X Y Z U V
// UV are remapped, so loads image texture as it is
// UVs are much easier to use in this state rather than indices
// bottom
-hlX, -hlY, -hlZ, 0.0f, 0.0f,
hlX, -hlY, -hlZ, 1.0f, 0.0f,
-hlX, -hlY, hlZ, 0.0f, 1.0f,
hlX, -hlY, -hlZ, 1.0f, 0.0f,
hlX, -hlY, hlZ, 1.0f, 1.0f,
-hlX, -hlY, hlZ, 0.0f, 1.0f,
// top
-hlX, hlY, -hlZ, 0.0f, 1.0f,
-hlX, hlY, hlZ, 0.0f, 0.0f,
hlX, hlY, -hlZ, 1.0f, 1.0f,
hlX, hlY, -hlZ, 1.0f, 1.0f,
-hlX, hlY, hlZ, 0.0f, 0.0f,
hlX, hlY, hlZ, 1.0f, 0.0f,
// back
-hlX, -hlY, hlZ, 1.0f, 1.0f,
hlX, -hlY, hlZ, 0.0f, 1.0f,
-hlX, hlY, hlZ, 1.0f, 0.0f,
hlX, -hlY, hlZ, 0.0f, 1.0f,
hlX, hlY, hlZ, 0.0f, 0.0f,
-hlX, hlY, hlZ, 1.0f, 0.0f,
// front
-hlX, -hlY, -hlZ, 0.0f, 1.0f,
-hlX, hlY, -hlZ, 0.0f, 0.0f,
hlX, -hlY, -hlZ, 1.0f, 1.0f,
hlX, -hlY, -hlZ, 1.0f, 1.0f,
-hlX, hlY, -hlZ, 0.0f, 0.0f,
hlX, hlY, -hlZ, 1.0f, 0.0f,
// left
-hlX, -hlY, hlZ, 0.0f, 1.0f,
-hlX, hlY, -hlZ, 1.0f, 0.0f,
-hlX, -hlY, -hlZ, 1.0f, 1.0f,
-hlX, -hlY, hlZ, 0.0f, 1.0f,
-hlX, hlY, hlZ, 0.0f, 0.0f,
-hlX, hlY, -hlZ, 1.0f, 0.0f,
// right
hlX, -hlY, hlZ, 1.0f, 1.0f,
hlX, -hlY, -hlZ, 0.0f, 1.0f,
hlX, hlY, -hlZ, 0.0f, 0.0f,
hlX, -hlY, hlZ, 1.0f, 1.0f,
hlX, hlY, -hlZ, 0.0f, 0.0f,
hlX, hlY, hlZ, 1.0f, 0.0f
};
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void Primitive3d::setAmbientLightColor(SDL_Colorf c, float i) {
ambientLightColor = c;
ambientLightIntensity = i;
}
void Cuboid::draw() {
glUseProgram(shaderProgram);
glUniformMatrix4fv(mvpLocation, 1, GL_TRUE, (const GLfloat*)transformer.transform());
glUniform4f(colorLocation, color.r, color.g, color.b, 1.0f);
glUniform3f(lightColorLocation, ambientLightColor.r, ambientLightColor.g, ambientLightColor.b);
glUniform1f(lightIntensityLocation, ambientLightIntensity);
if (0 != textureID) { // check if texture exists
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureID);
glUniform1i(useTextureLocation, 1); // use texture (1) or use color (0)
}
else {
glUniform1i(useTextureLocation, 0);
}
glUniform1i(useUI, 0);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), 0); // x,y,z, repeat every 5 values
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_TRUE, 5 * sizeof(GLfloat), (const GLvoid*)(3 * sizeof(GLfloat))); // u,v start at 3, repeat 5
glDrawArrays(GL_TRIANGLES, 0, 36); // Cuboid 12*3
// unbind everything
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glUseProgram(0);
}
/* CUBE CLASS DEFINITION */
Cube::Cube(const Point3f & center, float size, SDL_Color color)
: Cuboid(center, size, size, size, color) {}
Cube::Cube(const Point3f & center, float size, GLuint textureID)
: Cuboid(center, size, size, size, textureID) {}
/* SPHERE CLASS DEFINITION */
Sphere::Sphere(const Point3f & center, const float & radius, GLuint textureID)
: Primitive3d(center, radius, radius, radius, textureID) {
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
stacks = 100;
slices = 30;
float const R = 1.0f / (float)(stacks - 1);
float const S = 1.0f / (float)(slices - 1);
int r = 0, s = 0;
int n = 2 * (slices + 1) * stacks;
int i = 0;
Vector3f * points = new Vector3f[n * 2];
for (float theta = -M_PI / 2; theta < M_PI / 2 - 0.0001; theta += M_PI / stacks) {
for (float phi = -M_PI; phi <= M_PI + 0.0001; phi += 2 * M_PI / slices) {
float x = radius * sin(theta) * cos(phi);
float y = radius * sin(theta) * sin(phi);
float z = radius * cos(theta);
points[i++] = Vector3f(x, y, z);
points[i++] = Vector3f(s*S, r*R, 0);
s++;
points[i++] = Vector3f(-x, -y, -z);
points[i++] = Vector3f(s*S, r*R, 0);
s++;
}
r++;
}
glBufferData(GL_ARRAY_BUFFER, i * sizeof(Vector3f), points, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
delete[] points;
}
Sphere::Sphere(const Point3f & center, const float & radius, SDL_Color color)
: Primitive3d(center, radius, radius, radius, color) {
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
stacks = 100;
slices = 30;
float const R = 1.0f / (float)(stacks - 1);
float const S = 1.0f / (float)(slices - 1);
int r = 0, s = 0;
int n = 2 * (slices + 1) * stacks;
int i = 0;
Vector3f * points = new Vector3f[n*2];
for (float theta = -M_PI / 2; theta < M_PI / 2 - 0.0001; theta += M_PI / stacks) {
for (float phi = -M_PI; phi <= M_PI + 0.0001; phi += 2 * M_PI / slices) {
float x = radius * sin(theta) * cos(phi);
float y = radius * sin(theta) * sin(phi);
float z = radius * cos(theta);
points[i++] = Vector3f(x, y, z);
points[i++] = Vector3f(s*S, r*R, 0);
s++;
points[i++] = Vector3f(-x, -y, -z);
points[i++] = Vector3f(s*S, r*R, 0);
s++;
}
r++;
}
glBufferData(GL_ARRAY_BUFFER, i * sizeof(Vector3f), points, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
delete[] points;
}
void Sphere::draw() {
glUseProgram(shaderProgram);
glUniformMatrix4fv(mvpLocation, 1, GL_TRUE, (const GLfloat*)transformer.transform());
glUniform4f(colorLocation, color.r, color.g, color.b, 1.0f);
glUniform3f(lightColorLocation, ambientLightColor.r, ambientLightColor.g, ambientLightColor.b);
glUniform1f(lightIntensityLocation, ambientLightIntensity);
if (0 != textureID) { // check if texture exists
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureID);
glUniform1i(useTextureLocation, 1); // use texture (1) or use color (0)
}
else {
glUniform1i(useTextureLocation, 0);
}
glUniform1i(useUI, 0);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), 0); // x,y,z, repeat every 6 values
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_TRUE, 6 * sizeof(GLfloat), (const GLvoid*)(3 * sizeof(GLfloat))); // u,v start at 3, repeat 6
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 2 * (stacks + 1) * slices);
glCullFace(GL_BACK);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 2 * (stacks + 1) * slices);
// unbind everything
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisable(GL_CULL_FACE);
glUseProgram(0);
}
|
AlmasB/tetris3d
|
src/engine/graphics/Primitives3d.cpp
|
C++
|
gpl-2.0
| 10,607 |
// license:BSD-3-Clause
// copyright-holders:Ernesto Corvi, Juergen Buchmueller, Alex Pasadyn, Aaron Giles, Nicola Salmoria
/***************************************************************************
Pole Position (c) 1982 Namco
Pole Position II (c) 1983 Namco
driver by Ernesto Corvi, Juergen Buchmueller, Alex Pasadyn, Aaron Giles, Nicola Salmoria
Custom ICs:
----------
CPU board:
06XX interface to custom 5xXX
07XX clock divider
08XX(x2) bus controller
10XX(x4) Z8002 bus controller
51XX I/O
52XX sample player
53XX I/O
54XX explosion sound generator
Video board:
02XX(x3) gfx data shifter and mixer (16-bit in, 4-bit out)
03XX(x2) ?
04XX sprite address generator
07XX clock divider
09XX address bus interface
Memory maps:
-----------
Part of the address decoding is done by PALs so it is inferred by program behaviour
Z80:
Address Dir Data Name Description
---------------- --- -------- --------- -----------------------
000xxxxxxxxxxxxx R xxxxxxxx ROM 7H program ROM
0010xxxxxxxxxxxx R xxxxxxxx ROM 7F program ROM
0011-xxxxxxxxxxx R/W xxxxxxxx CMOSRAMCS battery back-up RAM
010000xxxxxxxxxx R/W xxxxxxxx CSMB work RAM [1]
010000111xxxxxxx R/W xxxxxxxx portion holding sprite registers (POSI) [1]
010001xxxxxxxxxx R/W xxxxxxxx CSMD work RAM [1]
010001111xxxxxxx R/W xxxxxxxx portion holding sprite registers (SIZE, DATA) [1]
01001xxxxxxxxxxx R/W xxxxxxxx RAM 3F 1st half is road, 2nd half alpha tilemap [1]
01010xxxxxxxxxxx R/W xxxxxxxx RAM 3E background tilemap (1st half only) [1]
1000--xxxxxxxxxx R/W xxxxxxxx RAMCS work RAM
1000--1111xxxxxx R/W xxxxxxxx portion holding the sound registers
1001---0-------- R/W xxxxxxxx IODBENBL custom 06XX data
1001---1-------- R/W xxxxxxxx IODBENBL custom 06XX control
1010--00-------- R -------x READY +5V
1010--00-------- R ------x- READY 128V
1010--00-------- R -----x-- READY PWRUP (power line sense)
1010--00-------- R ----x--- READY ADC0804 INTR (end flag)
1010--01-------- R n.c.
1010--10-------- R n.c.
1010--11-------- R n.c.
1010--00-----000 W -------x IRQON Z80 IRQ enable/acknowledge
1010--00-----001 W -------x IOSEL reset 5xXX chips
1010--00-----010 W -------x CLSON sound enable [2]
1010--00-----011 W -------x GASEL accelerator/brake select
1010--00-----100 W -------x RESB reset Z8002 #1
1010--00-----101 W -------x RESA reset Z8002 #2
1010--00-----110 W -------x SB0 start (goes to 51XX start button input)
1010--00-----111 W -------x CHACL alpha layer enable color and msb
1010--01-------- W -------- WDR watchdog reset
1010--10-------- W -------x XSOUND engine enable
1010--10-------- W --xxxxx- XSOUND engine pitch lsb
1010--11-------- W --xxxxxx XSON engine pitch msb
[1] shared with the two Z8002, but the Z80 can only access the low 8 bits of these
16-bit areas
[2] affects wave and engine, but not 54XX and 52XX. Note that for the engine, this
clears the XSOUND and XSON latches.
Z80 I/O:
Address Dir Data Name Description
---------------- --- -------- --------- -----------------------
---------------- R xxxxxxxx ADC0804 (accelerator/brake pedals)
Z8002 #1:
Address Dir Data Name Description
---------------- --- ---------------- --------- -----------------------
00xxxxxxxxxxxxx- R xxxxxxxxxxxxxxxx ROM 4L/3L program ROM
01xxxxxxxxxxxxx- R xxxxxxxxxxxxxxxx ROM 4K/3K program ROM
011------------- W ---------------x NMIACKB Z8002 #2 NMI enable/acknowledge [1]
the rest of the memory map is common to the other Z8002
Z8002 #2:
Address Dir Data Name Description
---------------- --- ---------------- --------- -----------------------
00xxxxxxxxxxxxx- R xxxxxxxxxxxxxxxx ROM 4E/3E program ROM
01xxxxxxxxxxxxx- R xxxxxxxxxxxxxxxx ROM 4D/3D program ROM
011------------- W ---------------x NMIACKA Z8002 #1 NMI enable/acknowledge [1]
the rest of the memory map is common to the other Z8002
[1] One Z8002 writes at $6000 and the other at $6002, but they did it only for clarity
because the low address bits are ignored and the location is not shared.
Z8002 (common):
Address Dir Data Name Description
---------------- --- ---------------- --------- -----------------------
10000xxxxxxxxxx- R/W xxxxxxxxxxxxxxxx CSMA/CSMB work RAM
10000111xxxxxxx- R/W xxxxxxxxxxxxxxxx portion holding sprite registers (POSI)
10001xxxxxxxxxx- R/W xxxxxxxxxxxxxxxx CSMC/CSMD work RAM
10001111xxxxxxx- R/W xxxxxxxxxxxxxxxx portion holding sprite registers (SIZE, DATA)
1001xxxxxxxxxxx- R/W xxxxxxxxxxxxxxxx RAM 4F/3F 1st half is road, 2nd half alpha tilemap
1010xxxxxxxxxxx- R/W xxxxxxxxxxxxxxxx RAM 4E/3E background tilemap (1st half only)
11---000-------- W ------xxxxxxxxxx VHP background horizontal position
11---001-------- W ----xxxxxxxxxxxx RVP road vertical position
11---010-------- W n.c.
11---011-------- W n.c.
11---100-------- W n.c.
11---101-------- W n.c.
11---110-------- W n.c.
11---111-------- W n.c.
Namco vs Atari ROM names and locations
--------------------------------------
* = not present
Location ID (PP1) ID (PP2) Location ID (PP1) ID (PP2)
-------- ---------- ---------- -------- ------------------------ ----------
CPU 8M PP1-1 PP4-1 CPU 3L 136014-101 136014-176
CPU 8L PP1-2 PP4-2 CPU 4L 136014-102 136014-177
? PP1-3* PP4-3* CPU 3K 136014-112* *
? PP1-4* PP4-4* CPU 4K 136014-113* *
CPU 4M PP1-5 PP4-5 CPU 3E 136014-103 or 136014-203 136014-178
CPU 4L PP1-6 PP4-6 CPU 4E 136014-104 or 136014-204 136014-179
CPU 3M PP1-7* PP4-7 CPU 3D 136014-114* 136014-184
CPU 3L PP1-8* PP4-8 CPU 4D 136014-115* 136014-185
CPU 6H PP1-9 PP4-9 CPU 7H 136014-105 or 136014-160 136014-180
CPU 5H PP1-10 PP4-10 CPU 7F 136014-116 136014-183
CPU 2E PP1-11 <-- CPU 9C 136014-106 or 136014-147 <--
CPU 2F PP1-12 <-- CPU 9A 136014-108* *
CPU 1E PP1-13 <-- CPU 8C 136014-107* *
CPU 1F PP1-14 <-- CPU 8A 136014-109* *
CPU 6A PP1-15 PP4-15 CPU 12F 136014-110 or 136014-148 136014-181
CPU 5A PP1-16 PP4-16 CPU 12E 136014-111 or 136014-149 136014-182
? PP1-1[pal] <-- CPU 5C PAL-1 <--
? PP1-2[pal] <-- CPU 2N PAL-1 <--
? PP1-3[pal] <-- CPU 7C PAL-3 <--
CPU 9H PP1-4[bpr] <-- CPU 7L 136014-117 <--
CPU 3B PP1-5[bpr] <-- CPU 11D 136014-118 <--
VID 5N PP1-17 <-- VID 13J 136014-119 == 136014-150 <--
VID 5M PP1-18 <-- VID 12J 136014-120 == 136014-151 <--
VID 4N PP1-19 <-- VID 13K 136014-121 or 136014-152 136014-166
VID 4M PP1-20 <-- VID 12K 136014-122 or 136014-153 136014-167
VID 3N PP1-21 <-- VID 13L 136014-123 or 136014-154 136014-168
VID 3M PP1-22 <-- VID 12L 136014-124 or 136014-155 136014-169
VID 2N PP1-23* PP4-23 VID 13M 136014-129* 136014-175
VID 2M PP1-24* PP4-24 VID 12M 136014-130* 136014-174
VID 1N PP1-25 PP4-25 VID 13N 136014-125 or 136014-156 136014-170
VID 1M PP1-26 PP4-26 VID 12N 136014-126 or 136014-157 136014-171
VID 1L PP1-27 <-- VID 11N 136014-131 or 136014-231 <--
VID 1F PP1-28 PP4-28 VID 7N 136014-132 or 137205-001? 136014-172
VID 1E PP1-29 PP4-29 VID 6N 136014-133 or 137205-001? 136014-173
VID 3A PP1-30 <-- VID 2L 136014-127 == 136014-158 <--
VID 2A PP1-31 <-- VID 2M 136014-128 == 136014-159 <--
VID 1A PP1-32 <-- VID 2N 136014-134 or 137205-001? <--
VID 6M PP1-6[bpr] PP4-6[bpr] VID 12H 136014-146 136014-192
VID 8L PP1-7[bpr] PP4-7[bpr] VID 11E 136014-137 136014-186
VID 9L PP1-8[bpr] PP4-8[bpr] VID 11D 136014-138 136014-187
VID 10L PP1-9[bpr] PP4-9[bpr] VID 11C 136014-139 136014-188
VID 2H PP1-10[bpr] PP4-10[bpr] VID 8M 136014-140 136014-189
VID 4D PP1-11[bpr] PP4-11[bpr] VID 5K 136014-141 136014-190
VID 3C PP1-12[bpr] PP4-12[bpr] VID 4L 136014-145 136014-191
VID 8E PP1-13[bpr] <-- VID 6E 136014-135 <--
VID 9E PP1-14[bpr] <-- VID 6D 136014-136 <--
VID 9A PP1-15[bpr] <-- VID 2D 136014-142 <--
VID 10A PP1-16[bpr] <-- VID 2C 136014-143 <--
VID 11A PP1-17[bpr] <-- VID 2B 136014-144 <--
Notes:
-----
- Easter egg (both Pole Position and Pole Position II):
- enter service mode
- turn wheel to 04; change the shifter from LO to HI
- turn wheel to 45; change the shifter from LO to HI
- turn wheel to 55; change the shifter from LO to HI
- turn wheel to 56; change the shifter from LO to HI
- turn wheel to 91; change the shifter from LO to HI
(c) 1982 NAMCO LTD. will appear on the screen.
- To reset the high score table, enter service mode, press the accelerator and
change the shifter from LO to HI
- Pole Position II reports 'Manual Start' on the Test Mode. This is ok,
because they had to accommodate the hardware from Pole Position I to allow
track selection.
- Change POLEPOS_TOGGLE to 0 if you are using the original gearshift.
- The old version of the vertical scaling ROM, 136014-131, has (apart from
some irrelevant differences) one bad bit.
This seems to be a genuine error on Atari's part, since they replaced it with
136014-231 which matches Namco's PP1-27. The bad bit should cause a tiny gfx
glitch, though it's difficult to notice.
Todo:
- the bootlegs without Namco devices (topracern, polepos2bi) still require
our 06xx and 51xx emulation to boot, this is incorrect.
***************************************************************************/
#include "emu.h"
#include "cpu/z80/z80.h"
#include "cpu/z8000/z8000.h"
#include "cpu/mb88xx/mb88xx.h"
#include "machine/namco06.h"
#include "machine/namco51.h"
#include "machine/namco53.h"
#include "audio/namco52.h"
#include "audio/namco54.h"
#include "includes/polepos.h"
#include "sound/tms5220.h"
#include "machine/nvram.h"
#include "polepos.lh"
#include "topracer.lh"
#define MASTER_CLOCK XTAL_24_576MHz
#define POLEPOS_TOGGLE PORT_TOGGLE
/*************************************************************************************/
/* Pole Position II protection */
/*************************************************************************************/
READ16_MEMBER(polepos_state::polepos2_ic25_r)
{
int result;
/* protection states */
offset = offset & 0x1ff;
if (offset < 0x100)
{
m_last_signed = offset & 0xff;
result = m_last_result & 0xff;
}
else
{
m_last_unsigned = offset & 0xff;
result = (m_last_result >> 8) & 0xff;
m_last_result = (INT8)m_last_signed * (UINT8)m_last_unsigned;
}
// logerror("%04X: read IC25 @ %04X = %02X\n", space.device().safe_pc(), offset, result);
return result | (result << 8);
}
READ8_MEMBER(polepos_state::polepos_adc_r)
{
return ioport(m_adc_input ? "ACCEL" : "BRAKE")->read();
}
READ8_MEMBER(polepos_state::polepos_ready_r)
{
int ret = 0xff;
if (m_screen->vpos() >= 128)
ret ^= 0x02;
ret ^= 0x08; /* ADC End Flag */
return ret;
}
WRITE8_MEMBER(polepos_state::polepos_latch_w)
{
int bit = data & 1;
switch (offset)
{
case 0x00: /* IRQON */
m_main_irq_mask = bit;
if (!bit)
m_maincpu->set_input_line(0, CLEAR_LINE);
break;
case 0x01: /* IOSEL */
// polepos_mcu_enable_w(offset,data);
break;
case 0x02: /* CLSON */
m_namco_sound->polepos_sound_enable(bit);
if (!bit)
{
machine().device<polepos_sound_device>("polepos")->polepos_engine_sound_lsb_w(space, 0, 0);
machine().device<polepos_sound_device>("polepos")->polepos_engine_sound_msb_w(space, 0, 0);
}
break;
case 0x03: /* GASEL */
m_adc_input = bit;
break;
case 0x04: /* RESB */
m_subcpu->set_input_line(INPUT_LINE_RESET, bit ? CLEAR_LINE : ASSERT_LINE);
break;
case 0x05: /* RESA */
m_subcpu2->set_input_line(INPUT_LINE_RESET, bit ? CLEAR_LINE : ASSERT_LINE);
break;
case 0x06: /* SB0 */
m_auto_start_mask = !bit;
break;
case 0x07: /* CHACL */
polepos_chacl_w(space,offset,data);
break;
}
}
WRITE16_MEMBER(polepos_state::polepos_z8002_nvi_enable_w)
{
data &= 1;
m_sub_irq_mask = data;
if (!data)
space.device().execute().set_input_line(0, CLEAR_LINE);
}
CUSTOM_INPUT_MEMBER(polepos_state::high_port_r){ return ioport((const char *)param)->read() >> 4; }
CUSTOM_INPUT_MEMBER(polepos_state::low_port_r){ return ioport((const char *)param)->read() & 0x0f; }
CUSTOM_INPUT_MEMBER(polepos_state::auto_start_r)
{
return m_auto_start_mask;
}
WRITE8_MEMBER(polepos_state::out_0)
{
// no start lamps in pole position
// output().set_led_value(1,data & 1);
// output().set_led_value(0,data & 2);
machine().bookkeeping().coin_counter_w(1,~data & 4);
machine().bookkeeping().coin_counter_w(0,~data & 8);
}
WRITE8_MEMBER(polepos_state::out_1)
{
machine().bookkeeping().coin_lockout_global_w(data & 1);
}
READ8_MEMBER(polepos_state::namco_52xx_rom_r)
{
UINT32 length = memregion("52xx")->bytes();
logerror("ROM @ %04X\n", offset);
return (offset < length) ? memregion("52xx")->base()[offset] : 0xff;
}
READ8_MEMBER(polepos_state::namco_52xx_si_r)
{
/* pulled to +5V */
return 1;
}
READ8_MEMBER(polepos_state::namco_53xx_k_r)
{
/* hardwired to 0 */
return 0;
}
READ8_MEMBER(polepos_state::steering_changed_r)
{
/* read the current steering value and update our delta */
UINT8 steer_new = ioport("STEER")->read();
m_steer_accum += (INT8)(steer_new - m_steer_last) * 2;
m_steer_last = steer_new;
/* if we have delta, clock things */
if (m_steer_accum < 0)
{
m_steer_delta = 0;
m_steer_accum++;
}
else if (m_steer_accum > 0)
{
m_steer_delta = 1;
m_steer_accum--;
}
return m_steer_accum & 1;
}
READ8_MEMBER(polepos_state::steering_delta_r)
{
return m_steer_delta;
}
TIMER_DEVICE_CALLBACK_MEMBER(polepos_state::polepos_scanline)
{
int scanline = param;
if (((scanline == 64) || (scanline == 192)) && m_main_irq_mask) // 64V
m_maincpu->set_input_line(0, ASSERT_LINE);
if (scanline == 240 && m_sub_irq_mask) // VBLANK
{
m_subcpu->set_input_line(0, ASSERT_LINE);
m_subcpu2->set_input_line(0, ASSERT_LINE);
}
}
MACHINE_RESET_MEMBER(polepos_state,polepos)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
int i;
/* Reset all latches */
for (i = 0; i < 8; i++)
polepos_latch_w(space, i, 0);
/* set the interrupt vectors (this shouldn't be needed) */
m_subcpu->set_input_line_vector(0, Z8000_NVI);
m_subcpu2->set_input_line_vector(0, Z8000_NVI);
}
/*********************************************************************
* CPU memory structures
*********************************************************************/
static ADDRESS_MAP_START( z80_map, AS_PROGRAM, 8, polepos_state )
AM_RANGE(0x0000, 0x2fff) AM_ROM
AM_RANGE(0x3000, 0x37ff) AM_MIRROR(0x0800) AM_RAM AM_SHARE("nvram") /* Battery Backup */
AM_RANGE(0x4000, 0x47ff) AM_READWRITE(polepos_sprite_r, polepos_sprite_w) /* Motion Object */
AM_RANGE(0x4800, 0x4bff) AM_READWRITE(polepos_road_r, polepos_road_w) /* Road Memory */
AM_RANGE(0x4c00, 0x4fff) AM_READWRITE(polepos_alpha_r, polepos_alpha_w) /* Alphanumeric (char ram) */
AM_RANGE(0x5000, 0x57ff) AM_READWRITE(polepos_view_r, polepos_view_w) /* Background Memory */
AM_RANGE(0x8000, 0x83bf) AM_MIRROR(0x0c00) AM_RAM /* Sound Memory */
AM_RANGE(0x83c0, 0x83ff) AM_MIRROR(0x0c00) AM_DEVREADWRITE("namco", namco_device, polepos_sound_r, polepos_sound_w) /* Sound data */
AM_RANGE(0x9000, 0x9000) AM_MIRROR(0x0eff) AM_DEVREADWRITE("06xx", namco_06xx_device, data_r, data_w)
AM_RANGE(0x9100, 0x9100) AM_MIRROR(0x0eff) AM_DEVREADWRITE("06xx", namco_06xx_device, ctrl_r, ctrl_w)
AM_RANGE(0xa000, 0xa000) AM_MIRROR(0x0cff) AM_READ(polepos_ready_r) /* READY */
AM_RANGE(0xa000, 0xa007) AM_MIRROR(0x0cf8) AM_WRITE(polepos_latch_w) /* misc latches */
AM_RANGE(0xa100, 0xa100) AM_MIRROR(0x0cff) AM_WRITE(watchdog_reset_w) /* Watchdog */
AM_RANGE(0xa200, 0xa200) AM_MIRROR(0x0cff) AM_DEVWRITE("polepos", polepos_sound_device, polepos_engine_sound_lsb_w) /* Car Sound ( Lower Nibble ) */
AM_RANGE(0xa300, 0xa300) AM_MIRROR(0x0cff) AM_DEVWRITE("polepos", polepos_sound_device, polepos_engine_sound_msb_w) /* Car Sound ( Upper Nibble ) */
ADDRESS_MAP_END
static ADDRESS_MAP_START( z80_io, AS_IO, 8, polepos_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_READ(polepos_adc_r) AM_WRITENOP
ADDRESS_MAP_END
/* the same memory map is used by both Z8002 CPUs; all RAM areas are shared */
static ADDRESS_MAP_START( z8002_map, AS_PROGRAM, 16, polepos_state )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x6000, 0x6001) AM_MIRROR(0x0ffe) AM_WRITE(polepos_z8002_nvi_enable_w) /* NVI enable - *NOT* shared by the two CPUs */
AM_RANGE(0x8000, 0x8fff) AM_READWRITE(polepos_sprite16_r, polepos_sprite16_w) AM_SHARE("sprite16_memory") /* Motion Object */
AM_RANGE(0x9000, 0x97ff) AM_READWRITE(polepos_road16_r, polepos_road16_w) AM_SHARE("road16_memory") /* Road Memory */
AM_RANGE(0x9800, 0x9fff) AM_READWRITE(polepos_alpha16_r, polepos_alpha16_w) AM_SHARE("alpha16_memory") /* Alphanumeric (char ram) */
AM_RANGE(0xa000, 0xafff) AM_READWRITE(polepos_view16_r, polepos_view16_w) AM_SHARE("view16_memory") /* Background memory */
AM_RANGE(0xc000, 0xc001) AM_MIRROR(0x38fe) AM_WRITE(polepos_view16_hscroll_w) /* Background horz scroll position */
AM_RANGE(0xc100, 0xc101) AM_MIRROR(0x38fe) AM_WRITE(polepos_road16_vscroll_w) /* Road vertical position */
ADDRESS_MAP_END
/*********************************************************************
* Input port definitions
*********************************************************************/
static INPUT_PORTS_START( polepos )
PORT_START("IN0L")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gear Change") PORT_CODE(KEYCODE_SPACE) POLEPOS_TOGGLE /* Gear */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, polepos_state,auto_start_r, NULL) // start 1, program controlled
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_START("IN0H")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
PORT_START("DSWA")
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2,3")
PORT_DIPSETTING( 0x05, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 1C_6C ) )
PORT_DIPNAME( 0x18, 0x18, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:4,5")
PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x18, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) )
PORT_DIPNAME( 0x60, 0x60, DEF_STR( Game_Time ) ) PORT_DIPLOCATION("SW1:6,7")
PORT_DIPSETTING( 0x60, "90 secs." )
PORT_DIPSETTING( 0x20, "100 secs." )
PORT_DIPSETTING( 0x40, "110 secs." )
PORT_DIPSETTING( 0x00, "120 secs." )
PORT_DIPNAME( 0x80, 0x80, "Racing Laps" ) PORT_DIPLOCATION("SW1:8")
PORT_DIPSETTING( 0x80, "3" ) /* Manufacturer's recommended settings for Upright cabinet */
PORT_DIPSETTING( 0x00, "4" ) /* Manufacturer's recommended settings for Sit-Down cabinet */
PORT_START("DSWA_HI")
PORT_BIT( 0x0f, 0x00, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, polepos_state,high_port_r, "DSWA")
PORT_START("DSWB")
PORT_DIPNAME( 0x07, 0x03, "Extended Rank" ) PORT_DIPLOCATION("SW2:1,2,3")
PORT_DIPSETTING( 0x07, "A" )
PORT_DIPSETTING( 0x03, "B" )
PORT_DIPSETTING( 0x05, "C" )
PORT_DIPSETTING( 0x01, "D" )
PORT_DIPSETTING( 0x06, "E" )
PORT_DIPSETTING( 0x02, "F" )
PORT_DIPSETTING( 0x04, "G" )
PORT_DIPSETTING( 0x00, "H" )
PORT_DIPNAME( 0x38, 0x28, "Practice Rank" ) PORT_DIPLOCATION("SW2:4,5,6")
PORT_DIPSETTING( 0x38, "A" )
PORT_DIPSETTING( 0x18, "B" )
PORT_DIPSETTING( 0x28, "C" )
PORT_DIPSETTING( 0x08, "D" )
PORT_DIPSETTING( 0x30, "E" )
PORT_DIPSETTING( 0x10, "F" )
PORT_DIPSETTING( 0x20, "G" )
PORT_DIPSETTING( 0x00, "H" )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:7") /* Is MPH or Km/H for "English" regions, but only Km/H for Japan ;-) */
PORT_DIPSETTING( 0x40, DEF_STR( Off) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ))
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("DSWB_HI")
PORT_BIT( 0x0f, 0x00, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, polepos_state,high_port_r, "DSWB")
PORT_START("BRAKE")
PORT_BIT( 0xff, 0x00, IPT_PEDAL2 ) PORT_MINMAX(0,0x90) PORT_SENSITIVITY(100) PORT_KEYDELTA(16)
PORT_START("ACCEL")
PORT_BIT( 0xff, 0x00, IPT_PEDAL ) PORT_MINMAX(0,0x90) PORT_SENSITIVITY(100) PORT_KEYDELTA(16)
PORT_START("STEER")
PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(30) PORT_KEYDELTA(4)
INPUT_PORTS_END
static INPUT_PORTS_START( poleposa )
PORT_INCLUDE( polepos )
PORT_MODIFY("DSWA")
PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2,3")
PORT_DIPSETTING( 0xc0, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x40, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x80, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0xe0, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x60, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0xa0, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
PORT_DIPNAME( 0x18, 0x18, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:4,5")
PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x10, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0x18, DEF_STR( 1C_1C ) )
PORT_DIPNAME( 0x06, 0x06, DEF_STR( Game_Time ) ) PORT_DIPLOCATION("SW1:6,7")
PORT_DIPSETTING( 0x06, "90 secs." )
PORT_DIPSETTING( 0x02, "100 secs." )
PORT_DIPSETTING( 0x04, "110 secs." )
PORT_DIPSETTING( 0x00, "120 secs." )
PORT_DIPNAME( 0x01, 0x01, "Racing Laps" ) PORT_DIPLOCATION("SW1:8")
PORT_DIPSETTING( 0x01, "3" ) /* Manufacturer's recommended settings for Upright cabinet */
PORT_DIPSETTING( 0x00, "4" ) /* Manufacturer's recommended settings for Sit-Down cabinet */
PORT_MODIFY("DSWB")
PORT_DIPNAME( 0xe0, 0x60, "Practice Rank" ) PORT_DIPLOCATION("SW2:1,2,3")
PORT_DIPSETTING( 0xe0, "A" )
PORT_DIPSETTING( 0x60, "B" )
PORT_DIPSETTING( 0xa0, "C" )
PORT_DIPSETTING( 0x20, "D" )
PORT_DIPSETTING( 0xc0, "E" )
PORT_DIPSETTING( 0x40, "F" )
PORT_DIPSETTING( 0x80, "G" )
PORT_DIPSETTING( 0x00, "H" )
PORT_DIPNAME( 0x1c, 0x14, "Extended Rank" ) PORT_DIPLOCATION("SW2:4,5,6")
PORT_DIPSETTING( 0x1c, "A" )
PORT_DIPSETTING( 0x0c, "B" )
PORT_DIPSETTING( 0x14, "C" )
PORT_DIPSETTING( 0x04, "D" )
PORT_DIPSETTING( 0x18, "E" )
PORT_DIPSETTING( 0x08, "F" )
PORT_DIPSETTING( 0x10, "G" )
PORT_DIPSETTING( 0x00, "H" )
PORT_DIPNAME( 0x02, 0x00, "Speed Unit" ) PORT_DIPLOCATION("SW2:7") /* MPH as per Atari manuals for the US regions */
PORT_DIPSETTING( 0x00, "mph" )
PORT_DIPSETTING( 0x02, "km/h" )
PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
PORT_DIPSETTING( 0x01, DEF_STR( Off ))
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
INPUT_PORTS_END
static INPUT_PORTS_START( topracern )
PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gear Change") PORT_CODE(KEYCODE_SPACE) POLEPOS_TOGGLE /* Gear */
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
PORT_START("IN0L")
PORT_BIT( 0x0f, 0x00, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, polepos_state,low_port_r, "IN0")
PORT_START("IN0H")
PORT_BIT( 0x0f, 0x00, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, polepos_state,high_port_r, "IN0")
PORT_START("DSWA")
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
PORT_DIPSETTING( 0x05, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 1C_6C ) )
PORT_DIPNAME( 0x18, 0x18, DEF_STR( Coin_B ) )
PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x18, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) )
PORT_DIPNAME( 0x60, 0x60, DEF_STR( Game_Time ) )
PORT_DIPSETTING( 0x60, "90 secs." )
PORT_DIPSETTING( 0x20, "100 secs." )
PORT_DIPSETTING( 0x40, "110 secs." )
PORT_DIPSETTING( 0x00, "120 secs." )
PORT_DIPNAME( 0x80, 0x80, "Racing Laps" )
PORT_DIPSETTING( 0x80, "3" )
PORT_DIPSETTING( 0x00, "4" )
PORT_START("DSWA_HI")
PORT_BIT( 0x0f, 0x00, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, polepos_state,high_port_r, "DSWA")
/* FIXME: these dips don't work and may not even exist on this bootleg */
PORT_START("DSWB")
PORT_DIPNAME( 0x07, 0x07, "Extended Rank" )
PORT_DIPSETTING( 0x07, "A" )
PORT_DIPSETTING( 0x03, "B" )
PORT_DIPSETTING( 0x05, "C" )
PORT_DIPSETTING( 0x01, "D" )
PORT_DIPSETTING( 0x06, "E" )
PORT_DIPSETTING( 0x02, "F" )
PORT_DIPSETTING( 0x04, "G" )
PORT_DIPSETTING( 0x00, "H" )
PORT_DIPNAME( 0x38, 0x38, "Practice Rank" )
PORT_DIPSETTING( 0x38, "A" )
PORT_DIPSETTING( 0x18, "B" )
PORT_DIPSETTING( 0x28, "C" )
PORT_DIPSETTING( 0x08, "D" )
PORT_DIPSETTING( 0x30, "E" )
PORT_DIPSETTING( 0x10, "F" )
PORT_DIPSETTING( 0x20, "G" )
PORT_DIPSETTING( 0x00, "H" )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ))
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("DSWB_HI")
PORT_BIT( 0x0f, 0x00, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, polepos_state,high_port_r, "DSWB")
PORT_START("BRAKE")
PORT_BIT( 0xff, 0x00, IPT_PEDAL2 ) PORT_MINMAX(0,0x90) PORT_SENSITIVITY(100) PORT_KEYDELTA(16)
PORT_START("ACCEL")
PORT_BIT( 0xff, 0x00, IPT_PEDAL ) PORT_MINMAX(0,0x90) PORT_SENSITIVITY(100) PORT_KEYDELTA(16)
PORT_START("STEER")
PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(30) PORT_KEYDELTA(4)
INPUT_PORTS_END
static INPUT_PORTS_START( polepos2 )
PORT_INCLUDE( polepos )
PORT_MODIFY("DSWA")
PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2,3")
PORT_DIPSETTING( 0xc0, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x40, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x80, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0xe0, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x60, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0xa0, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
PORT_DIPNAME( 0x18, 0x18, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:4,5")
PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x10, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0x18, DEF_STR( 1C_1C ) )
PORT_DIPNAME( 0x04, 0x00, "Speed Unit" ) PORT_DIPLOCATION("SW1:6") /* Set default to MPH for "English" regions */
PORT_DIPSETTING( 0x00, "mph" )
PORT_DIPSETTING( 0x04, "km/h" )
PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW1:7")
PORT_DIPSETTING( 0x00, DEF_STR( Off ))
PORT_DIPSETTING( 0x02, DEF_STR( On ) )
PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:8") /* docs say "freeze", but it doesn't seem to work */
PORT_DIPSETTING( 0x01, DEF_STR( Off ))
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_MODIFY("DSWB")
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Game_Time ) ) PORT_DIPLOCATION("SW2:1")
PORT_DIPSETTING( 0x80, "90 secs." )
PORT_DIPSETTING( 0x00, "120 secs." )
PORT_DIPNAME( 0x60, 0x60, "Practice Rank" ) PORT_DIPLOCATION("SW2:2,3")
PORT_DIPSETTING( 0x20, "A" )
PORT_DIPSETTING( 0x60, "B" )
PORT_DIPSETTING( 0x40, "C" )
PORT_DIPSETTING( 0x00, "D" )
PORT_DIPNAME( 0x18, 0x18, "Extended Rank" ) PORT_DIPLOCATION("SW2:4,5")
PORT_DIPSETTING( 0x08, "A" )
PORT_DIPSETTING( 0x18, "B" )
PORT_DIPSETTING( 0x10, "C" )
PORT_DIPSETTING( 0x00, "D" )
PORT_DIPNAME( 0x06, 0x06, "Goal" ) PORT_DIPLOCATION("SW2:6,7")
PORT_DIPSETTING( 0x02, "3" )
PORT_DIPSETTING( 0x06, "4" )
PORT_DIPSETTING( 0x04, "5" )
PORT_DIPSETTING( 0x00, "6" )
PORT_DIPNAME( 0x01, 0x01, "Speed" ) PORT_DIPLOCATION("SW2:8")
PORT_DIPSETTING( 0x01, "Average" )
PORT_DIPSETTING( 0x00, DEF_STR( High ) )
INPUT_PORTS_END
static INPUT_PORTS_START( polepos2j )
PORT_INCLUDE( polepos2 )
PORT_MODIFY("DSWA")
PORT_DIPNAME( 0x04, 0x04, "Speed Unit" ) PORT_DIPLOCATION("SW1:6") /* Set default to km/h for Japan */
PORT_DIPSETTING( 0x00, "mph" )
PORT_DIPSETTING( 0x04, "km/h" )
INPUT_PORTS_END
/*********************************************************************
* Graphics layouts
*********************************************************************/
static const gfx_layout charlayout_2bpp =
{
8,8,
RGN_FRAC(1,1),
2,
{ 0, 4 },
{ 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
8*8*2
};
static const gfx_layout bigspritelayout =
{
32,32,
RGN_FRAC(1,2),
4,
{ 0, 4, RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4 },
{ 0, 1, 2, 3, 8, 9, 10, 11,
16, 17, 18, 19, 24, 25, 26, 27,
32, 33, 34, 35, 40, 41, 42, 43,
48, 49, 50, 51, 56, 57, 58, 59},
{ 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64,
16*64, 17*64, 18*64, 19*64, 20*64, 21*64, 22*64, 23*64,
24*64, 25*64, 26*64, 27*64, 28*64, 29*64, 30*64, 31*64 },
32*64
};
static const gfx_layout smallspritelayout =
{
16,16,
RGN_FRAC(1,2),
4,
{ 0, 4, RGN_FRAC(1,2), RGN_FRAC(1,2)+4
},
{ 0, 1, 2, 3, 8, 9, 10, 11,
16, 17, 18, 19, 24, 25, 26, 27 },
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
16*32
};
static GFXDECODE_START( polepos )
GFXDECODE_ENTRY( "gfx1", 0, charlayout_2bpp, 0x0000, 128 )
GFXDECODE_ENTRY( "gfx2", 0, charlayout_2bpp, 0x0200, 64 )
GFXDECODE_ENTRY( "gfx3", 0, smallspritelayout, 0x0300, 128 )
GFXDECODE_ENTRY( "gfx4", 0, bigspritelayout, 0x0300, 128 )
GFXDECODE_END
/*********************************************************************
* Machine driver
*********************************************************************/
static MACHINE_CONFIG_START( polepos, polepos_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK/8) /* 3.072 MHz */
MCFG_CPU_PROGRAM_MAP(z80_map)
MCFG_CPU_IO_MAP(z80_io)
MCFG_CPU_ADD("sub", Z8002, MASTER_CLOCK/8) /* 3.072 MHz */
MCFG_CPU_PROGRAM_MAP(z8002_map)
MCFG_CPU_ADD("sub2", Z8002, MASTER_CLOCK/8) /* 3.072 MHz */
MCFG_CPU_PROGRAM_MAP(z8002_map)
MCFG_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/8/2) /* 1.536 MHz */
MCFG_NAMCO_51XX_INPUT_0_CB(IOPORT("IN0L"))
MCFG_NAMCO_51XX_INPUT_1_CB(IOPORT("IN0H"))
MCFG_NAMCO_51XX_INPUT_2_CB(IOPORT("DSWB"))
MCFG_NAMCO_51XX_INPUT_3_CB(IOPORT("DSWB_HI"))
MCFG_NAMCO_51XX_OUTPUT_0_CB(WRITE8(polepos_state,out_0))
MCFG_NAMCO_51XX_OUTPUT_1_CB(WRITE8(polepos_state,out_1))
MCFG_NAMCO_52XX_ADD("52xx", MASTER_CLOCK/8/2) /* 1.536 MHz */
MCFG_NAMCO_52XX_DISCRETE("discrete")
MCFG_NAMCO_52XX_BASENODE(NODE_04)
MCFG_NAMCO_52XX_ROMREAD_CB(READ8(polepos_state,namco_52xx_rom_r))
MCFG_NAMCO_52XX_SI_CB(READ8(polepos_state,namco_52xx_si_r))
MCFG_NAMCO_53XX_ADD("53xx", MASTER_CLOCK/8/2) /* 1.536 MHz */
MCFG_NAMCO_53XX_K_CB(READ8(polepos_state,namco_53xx_k_r))
MCFG_NAMCO_53XX_INPUT_0_CB(READ8(polepos_state,steering_changed_r))
MCFG_NAMCO_53XX_INPUT_1_CB(READ8(polepos_state,steering_delta_r))
MCFG_NAMCO_53XX_INPUT_2_CB(IOPORT("DSWA"))
MCFG_NAMCO_53XX_INPUT_3_CB(IOPORT("DSWA_HI"))
MCFG_NAMCO_54XX_ADD("54xx", MASTER_CLOCK/8/2) /* 1.536 MHz */
MCFG_NAMCO_54XX_DISCRETE("discrete")
MCFG_NAMCO_54XX_BASENODE(NODE_01)
MCFG_NAMCO_06XX_ADD("06xx", MASTER_CLOCK/8/64)
MCFG_NAMCO_06XX_MAINCPU("maincpu")
MCFG_NAMCO_06XX_READ_0_CB(DEVREAD8("51xx", namco_51xx_device, read))
MCFG_NAMCO_06XX_WRITE_0_CB(DEVWRITE8("51xx", namco_51xx_device, write))
MCFG_NAMCO_06XX_READ_1_CB(DEVREAD8("53xx", namco_53xx_device, read))
MCFG_NAMCO_06XX_READ_REQUEST_1_CB(DEVWRITELINE("53xx", namco_53xx_device, read_request))
MCFG_NAMCO_06XX_WRITE_2_CB(DEVWRITE8("52xx", namco_52xx_device, write))
MCFG_NAMCO_06XX_WRITE_3_CB(DEVWRITE8("54xx", namco_54xx_device, write))
MCFG_WATCHDOG_VBLANK_INIT(16) // 128V clocks the same as VBLANK
MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* some interleaving */
MCFG_MACHINE_RESET_OVERRIDE(polepos_state,polepos)
MCFG_NVRAM_ADD_1FILL("nvram")
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", polepos_state, polepos_scanline, "screen", 0, 1)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS(MASTER_CLOCK/4, 384, 0, 256, 264, 16, 224+16)
MCFG_SCREEN_UPDATE_DRIVER(polepos_state, screen_update_polepos)
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", polepos)
MCFG_PALETTE_ADD("palette", 0x0f00)
MCFG_PALETTE_INDIRECT_ENTRIES(128)
MCFG_DEFAULT_LAYOUT(layout_polepos)
MCFG_PALETTE_INIT_OWNER(polepos_state,polepos)
MCFG_VIDEO_START_OVERRIDE(polepos_state,polepos)
/* sound hardware */
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD("namco", NAMCO, MASTER_CLOCK/512)
MCFG_NAMCO_AUDIO_VOICES(8)
MCFG_NAMCO_AUDIO_STEREO(1)
MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
/* discrete circuit on the 54XX outputs */
MCFG_SOUND_ADD("discrete", DISCRETE, 0)
MCFG_DISCRETE_INTF(polepos)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.90)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.90)
/* engine sound */
MCFG_SOUND_ADD("polepos", POLEPOS, 0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.90 * 0.77)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.90 * 0.77)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( topracern, polepos_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK/8) /* 3.072 MHz */
MCFG_CPU_PROGRAM_MAP(z80_map)
MCFG_CPU_IO_MAP(z80_io)
MCFG_CPU_ADD("sub", Z8002, MASTER_CLOCK/8) /* 3.072 MHz */
MCFG_CPU_PROGRAM_MAP(z8002_map)
MCFG_CPU_ADD("sub2", Z8002, MASTER_CLOCK/8) /* 3.072 MHz */
MCFG_CPU_PROGRAM_MAP(z8002_map)
/* todo, remove these devices too, this bootleg doesn't have them, but the emulation doesn't boot without them.. */
/* doesn't exist on the bootleg, but required for now or the game only boots in test mode!
they probably simulate some of the logic */
MCFG_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/8/2) /* 1.536 MHz */
MCFG_NAMCO_51XX_INPUT_1_CB(IOPORT("IN0H"))
MCFG_NAMCO_06XX_ADD("06xx", MASTER_CLOCK/8/64)
MCFG_NAMCO_06XX_MAINCPU("maincpu")
MCFG_NAMCO_06XX_READ_0_CB(DEVREAD8("51xx", namco_51xx_device, read))
MCFG_NAMCO_06XX_WRITE_0_CB(DEVWRITE8("51xx", namco_51xx_device, write))
MCFG_WATCHDOG_VBLANK_INIT(16) // 128V clocks the same as VBLANK
MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* some interleaving */
MCFG_MACHINE_RESET_OVERRIDE(polepos_state,polepos)
MCFG_NVRAM_ADD_1FILL("nvram")
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", polepos_state, polepos_scanline, "screen", 0, 1)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS(MASTER_CLOCK/4, 384, 0, 256, 264, 16, 224+16)
MCFG_SCREEN_UPDATE_DRIVER(polepos_state, screen_update_polepos)
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", polepos)
MCFG_PALETTE_ADD("palette", 0x0f00)
MCFG_PALETTE_INDIRECT_ENTRIES(128)
MCFG_DEFAULT_LAYOUT(layout_topracer)
MCFG_PALETTE_INIT_OWNER(polepos_state,polepos)
MCFG_VIDEO_START_OVERRIDE(polepos_state,polepos)
/* sound hardware */
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD("namco", NAMCO, MASTER_CLOCK/512)
MCFG_NAMCO_AUDIO_VOICES(8)
MCFG_NAMCO_AUDIO_STEREO(1)
MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
/* engine sound */
MCFG_SOUND_ADD("polepos", POLEPOS, 0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.90 * 0.77)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.90 * 0.77)
MACHINE_CONFIG_END
static ADDRESS_MAP_START( sound_z80_bootleg_map, AS_PROGRAM, 8, polepos_state )
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x2700, 0x27ff) AM_RAM
ADDRESS_MAP_END
static ADDRESS_MAP_START( sound_z80_bootleg_iomap, AS_IO, 8, polepos_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
ADDRESS_MAP_END
static MACHINE_CONFIG_DERIVED( polepos2bi, topracern )
MCFG_CPU_ADD("soundz80bl", Z80, MASTER_CLOCK/8) /*? MHz */
MCFG_CPU_PROGRAM_MAP(sound_z80_bootleg_map)
MCFG_CPU_IO_MAP(sound_z80_bootleg_iomap)
MCFG_SOUND_ADD("tms", TMS5220, 600000) /* ? Mhz */
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.80)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.80)
MACHINE_CONFIG_END
/*********************************************************************
* ROM definitions
*********************************************************************/
/*
Pole Position - Namco Version
*/
ROM_START( polepos )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "pp3_9.6h", 0x0000, 0x2000, CRC(c0511173) SHA1(88a1d4eefacbcf7d0e59edc0110edf225cad15c4) )
ROM_LOAD( "pp1_10b.5h", 0x2000, 0x1000, CRC(7174bcb7) SHA1(460326a6cea201db2df813013c95562a222ea95d) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "pp3_1.8m", 0x0001, 0x2000, CRC(65c1c2c2) SHA1(69f3e2e871f1cdc1efee91688acad4417683474d) )
ROM_LOAD16_BYTE( "pp3_2.8l", 0x0000, 0x2000, CRC(fafb9049) SHA1(92424c1042f520af115fb271fc11f4914a346ae2) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "pp3_5.4m", 0x0001, 0x2000, CRC(46e5c99a) SHA1(d5fd657a9197f1751f6fca430d3ef18d37ed774e) )
ROM_LOAD16_BYTE( "pp3_6.4l", 0x0000, 0x2000, CRC(acc1ebc3) SHA1(41745f5b6b0af2cb1ee80843194c070eac9e74e7) )
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "pp3_28.1f", 0x0000, 0x1000, CRC(2e77187e) SHA1(869a7389a684ccedd14868fb03400b1f8088acca) )
ROM_REGION( 0x01000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "pp1_29.1e", 0x0000, 0x1000, CRC(706e888a) SHA1(af1aa2199fcf73a3afbe760857ff117865350954) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "pp3_25.1n", 0x0000, 0x2000, CRC(b52c086b) SHA1(ea4a58fcc1d829ad0efa13a02f90fadc61e6e0bc) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "pp3_26.1m", 0x2000, 0x2000, CRC(d24a5707) SHA1(468319469bde6b7dc0cf8244299d8dc927059b2d) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "pp1_17.5n", 0x0000, 0x2000, CRC(2e134b46) SHA1(0938f5f9f5cc6d7c1096c569449db78dbc42da01) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "pp1_19.4n", 0x2000, 0x2000, CRC(43ff83e1) SHA1(8f830549a629b019125e59801e5027e4e4b3c0f2) )
ROM_LOAD( "pp1_21.3n", 0x4000, 0x2000, CRC(5f958eb4) SHA1(b56d84e5e5e0ddeb0e71851ba66e5fa1b1409551) )
ROM_LOAD( "pp1_18.5m", 0x8000, 0x2000, CRC(6f9997d2) SHA1(b26d505266ccf23bfd867f881756c3251c80f57b) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "pp1_20.4m", 0xa000, 0x2000, CRC(ec18075b) SHA1(af7be549c5fa47551a8dca4c0a531552147fa50f) )
ROM_LOAD( "pp1_22.3m", 0xc000, 0x2000, CRC(1d2f30b1) SHA1(1d88a3069e9b15febd2835dd63e5511b3b2a6b45) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "pp1_30.3a", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "pp1_31.2a", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "pp1_32.1a", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "pp1_27.1l", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "pp1-7.8l", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "pp1-8.9l", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "pp1-9.10l", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "pp2-10.2h", 0x0300, 0x0100, CRC(1e8d0491) SHA1(e8bf1db5c1fb04a35763099965cf5c588240bde5) ) /* alpha color - Same as pp1-10.2h - Verified */
ROM_LOAD( "pp1-11.4d", 0x0400, 0x0100, CRC(0e4fe8a0) SHA1(d330b1e5ebccf5bbefcf71486fd80d816de38196) ) /* background color */
ROM_LOAD( "pp1-15.9a", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "pp1-16.10a", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "pp1-17.11a", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "pp1-12.3c", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "pp3-6.6m", 0x0c00, 0x0400, CRC(63fb6057) SHA1(453fbdfd053c2a026cd41b57d0a71754b69a15da) ) /* sprite color */
ROM_LOAD( "pp1-13.8e", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "pp1-14.9e", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "pp1-5.3b", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "pp1_15.6a", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "pp1_16.5a", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
ROM_REGION( 0x8000, "52xx", 0 )
ROM_LOAD( "pp2_11.2e", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
ROM_LOAD( "pp2_12.2f", 0x2000, 0x2000, CRC(32b694c2) SHA1(101d9da28333ca290b0235eefb5ec9b094e1736e) ) /* voice */
ROM_LOAD( "pp2_13.1e", 0x4000, 0x2000, CRC(8842138a) SHA1(7e94f5b6ee32f6af37df54cfb72d96f9b543f9e2) ) /* voice */
/* No ROM PPx 14 is present. Empty socket on the PCB */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "pp1-4.9h", 0x0000, 0x0100, CRC(2401c817) SHA1(8991b7994513a469e64392fa8f233af5e5f06d54) ) /* sync chain */
ROM_END
ROM_START( poleposj )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "pp1_9b.6h", 0x0000, 0x2000, CRC(94436b70) SHA1(7495c2a8c3928c59146760d19e672afee01c5b17) )
ROM_LOAD( "pp1_10b.5h", 0x2000, 0x1000, CRC(7174bcb7) SHA1(460326a6cea201db2df813013c95562a222ea95d) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "pp1_1b.8m", 0x0001, 0x2000, CRC(361c56dd) SHA1(6e4abf98b10077c6980e8aa3861f0233135ea68f) )
ROM_LOAD16_BYTE( "pp1_2b.8l", 0x0000, 0x2000, CRC(582b530a) SHA1(4fc38aa8b70816e14b321ec778090f6c7e7f1640) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "pp1_5b.4m", 0x0001, 0x2000, CRC(5cdf5294) SHA1(dbdf327a541fd71aadafda9c925fa4cf7f7c4a24) )
ROM_LOAD16_BYTE( "pp1_6b.4l", 0x0000, 0x2000, CRC(81696272) SHA1(27041a7c24297a6f317537c44922b51d2b2278a6) )
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "pp1_28.1f", 0x0000, 0x1000, CRC(5b277daf) SHA1(0b1feeb2c0c63a5db5ba9b0115aa1b2388636a70) )
ROM_REGION( 0x01000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "pp1_29.1e", 0x0000, 0x1000, CRC(706e888a) SHA1(af1aa2199fcf73a3afbe760857ff117865350954) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "pp1_25.1n", 0x0000, 0x2000, CRC(ac8e28c1) SHA1(13bc2bf4be28d9ae987f79034f9532272b3a2543) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "pp1_26.1m", 0x2000, 0x2000, CRC(94443079) SHA1(413d7b762c8dff541675e96874be6ee0251d3581) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "pp1_17.5n", 0x0000, 0x2000, CRC(2e134b46) SHA1(0938f5f9f5cc6d7c1096c569449db78dbc42da01) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "pp1_19.4n", 0x2000, 0x2000, CRC(43ff83e1) SHA1(8f830549a629b019125e59801e5027e4e4b3c0f2) )
ROM_LOAD( "pp1_21.3n", 0x4000, 0x2000, CRC(5f958eb4) SHA1(b56d84e5e5e0ddeb0e71851ba66e5fa1b1409551) )
ROM_LOAD( "pp1_18.5m", 0x8000, 0x2000, CRC(6f9997d2) SHA1(b26d505266ccf23bfd867f881756c3251c80f57b) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "pp1_20.4m", 0xa000, 0x2000, CRC(ec18075b) SHA1(af7be549c5fa47551a8dca4c0a531552147fa50f) )
ROM_LOAD( "pp1_22.3m", 0xc000, 0x2000, CRC(1d2f30b1) SHA1(1d88a3069e9b15febd2835dd63e5511b3b2a6b45) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "pp1_30.3a", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "pp1_31.2a", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "pp1_32.1a", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "pp1_27.1l", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "pp1-7.8l", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "pp1-8.9l", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "pp1-9.10l", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "pp1-10.2h", 0x0300, 0x0100, CRC(1e8d0491) SHA1(e8bf1db5c1fb04a35763099965cf5c588240bde5) ) /* alpha color */
ROM_LOAD( "pp1-11.4d", 0x0400, 0x0100, CRC(0e4fe8a0) SHA1(d330b1e5ebccf5bbefcf71486fd80d816de38196) ) /* background color */
ROM_LOAD( "pp1-15.9a", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "pp1-16.10a", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "pp1-17.11a", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "pp1-12.3c", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "pp1-6.6m", 0x0c00, 0x0400, CRC(2f1079ee) SHA1(18a27998a78deff13dd198f3668a7e92f084f467) ) /* sprite color */
ROM_LOAD( "pp1-13.8e", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "pp1-14.9e", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "pp1-5.3b", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "pp1_15.6a", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "pp1_16.5a", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
ROM_REGION( 0x8000, "52xx", 0 )
ROM_LOAD( "pp1_11.2e", 0x0000, 0x2000, CRC(45b9bfeb) SHA1(ff8c690471944d414931fb88666594ef608997f8) ) /* voice */
ROM_LOAD( "pp1_12.2f", 0x2000, 0x2000, CRC(a31b4be5) SHA1(38298093bb97ea8647fe187359cae05b65e1c616) ) /* voice */
ROM_LOAD( "pp1_13.1e", 0x4000, 0x2000, CRC(a4237466) SHA1(88a397276038cc2fc05f2c18472e6b7cef167f2e) ) /* voice */
ROM_LOAD( "pp1_14.1f", 0x6000, 0x2000, CRC(944580f9) SHA1(c76f529cae718674ce97a1a599a3c6eaf6bf561a) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "pp1-4.9h", 0x0000, 0x0100, CRC(2401c817) SHA1(8991b7994513a469e64392fa8f233af5e5f06d54) ) /* sync chain */
ROM_END
/*
Pole Position - Atari Version
CPU/Sound Board: A039185
Video Board: A039187
*/
ROM_START( poleposa1 )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "136014.105", 0x0000, 0x2000, CRC(c918c043) SHA1(abc1aa3d7b670b5a65b4565dc646cd3c4edf4e6f) )
ROM_LOAD( "136014.116", 0x2000, 0x1000, CRC(7174bcb7) SHA1(460326a6cea201db2df813013c95562a222ea95d) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "136014.101", 0x0001, 0x2000, CRC(8c2cf172) SHA1(57c774afab79599ac3f434113c3170fbb3d42620) )
ROM_LOAD16_BYTE( "136014.102", 0x0000, 0x2000, CRC(51018857) SHA1(ed28d44d172a01f76461f556229d1fe3a1b779a7) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "136014.103", 0x0001, 0x2000, CRC(af4fc019) SHA1(1bb6c0f3ffada2e1df72e1767581f8e8bb2b18f9) )
ROM_LOAD16_BYTE( "136014.104", 0x0000, 0x2000, CRC(ba0045f3) SHA1(aedb8d8c56407963aa4ffb66243288c8fd6d845a) )
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "136014.132", 0x0000, 0x1000, CRC(a949aa85) SHA1(2d6414196b6071101001128418233e585279ffb9) )
ROM_REGION( 0x01000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "136014.133", 0x0000, 0x1000, CRC(3f0eb551) SHA1(39516d0f72f4e3b03df9451d2dbe081d6c71a508) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "136014.156", 0x0000, 0x2000, CRC(e7a09c93) SHA1(47cc5c6776333bba8454a3df9e2f6e7de4a465e1) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "136014.157", 0x2000, 0x2000, CRC(dee7d687) SHA1(ea34b51c91f6915b74a4a7b53ddb4ff36b72bf66) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "136014.150", 0x0000, 0x2000, CRC(2e134b46) SHA1(0938f5f9f5cc6d7c1096c569449db78dbc42da01) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "136014.152", 0x2000, 0x2000, CRC(a7e3a1c6) SHA1(b7340318afaa4b5f416fe4444899579242cd36c2) )
ROM_LOAD( "136014.154", 0x4000, 0x2000, CRC(8992d381) SHA1(3bf2544dbe88132137acec2c064a104a74139ec7) )
ROM_LOAD( "136014.151", 0x8000, 0x2000, CRC(6f9997d2) SHA1(b26d505266ccf23bfd867f881756c3251c80f57b) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "136014.153", 0xa000, 0x2000, CRC(6c5c6e68) SHA1(dce74ee0e69e0fc0a1942a489c2065381239f0f1) )
ROM_LOAD( "136014.155", 0xc000, 0x2000, CRC(111896ad) SHA1(15032b4c859231373bebfa640421fdcc8ba9d211) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "136014.158", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "136014.159", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "136014.134", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "136014.131", 0x0000, 0x1000, CRC(5921777f) SHA1(4d9c91a26e0d84fbbe08f748d6e0364311ed6f73) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "136014.137", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "136014.138", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "136014.139", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "136014.140", 0x0300, 0x0100, CRC(1e8d0491) SHA1(e8bf1db5c1fb04a35763099965cf5c588240bde5) ) /* alpha color */
ROM_LOAD( "136014.141", 0x0400, 0x0100, CRC(0e4fe8a0) SHA1(d330b1e5ebccf5bbefcf71486fd80d816de38196) ) /* background color */
ROM_LOAD( "136014.142", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "136014.143", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "136014.144", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "136014.145", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "136014.146", 0x0c00, 0x0400, CRC(ca4ba741) SHA1(de93d738bd27e24dbc4a8378d2c120ef8388c261) ) /* sprite color */
ROM_LOAD( "136014.135", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "136014.136", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "136014.118", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "136014.110", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "136014.111", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
ROM_REGION( 0x6000, "52xx", 0 )
ROM_LOAD( "136014.106", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "136014.117", 0x0000, 0x0100, CRC(2401c817) SHA1(8991b7994513a469e64392fa8f233af5e5f06d54) ) /* sync chain */
ROM_REGION( 0x0002, "cpu_pals", 0 ) /* PAL's located on the cpu board */
ROM_LOAD( "137316-001.2n", 0x0000, 0x0001, NO_DUMP ) /* MMI PAL16L6CN */
ROM_LOAD( "137316-00x.5c", 0x0000, 0x0001, NO_DUMP ) /* MMI PAL16L6CN */
ROM_END
ROM_START( poleposa2 )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "136014.105", 0x0000, 0x2000, CRC(c918c043) SHA1(abc1aa3d7b670b5a65b4565dc646cd3c4edf4e6f) )
ROM_LOAD( "136014.116", 0x2000, 0x1000, CRC(7174bcb7) SHA1(460326a6cea201db2df813013c95562a222ea95d) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "136014.101", 0x0001, 0x2000, CRC(8c2cf172) SHA1(57c774afab79599ac3f434113c3170fbb3d42620) )
ROM_LOAD16_BYTE( "136014.102", 0x0000, 0x2000, CRC(51018857) SHA1(ed28d44d172a01f76461f556229d1fe3a1b779a7) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "136014.203", 0x0001, 0x2000, CRC(eedea6e7) SHA1(e1459c5e3f824e589e624c3acb18a183fd160df6) )
ROM_LOAD16_BYTE( "136014.204", 0x0000, 0x2000, CRC(c52c98ed) SHA1(2e33c487deaf8afb941e07e511a9828d2d8f6b31) )
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "136014.132", 0x0000, 0x1000, CRC(a949aa85) SHA1(2d6414196b6071101001128418233e585279ffb9) )
ROM_REGION( 0x01000, "gfx2", 0 )
ROM_LOAD( "136014.133", 0x0000, 0x1000, CRC(3f0eb551) SHA1(39516d0f72f4e3b03df9451d2dbe081d6c71a508) ) /* 2bpp view layer */
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "136014.156", 0x0000, 0x2000, CRC(e7a09c93) SHA1(47cc5c6776333bba8454a3df9e2f6e7de4a465e1) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "136014.157", 0x2000, 0x2000, CRC(dee7d687) SHA1(ea34b51c91f6915b74a4a7b53ddb4ff36b72bf66) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "136014.150", 0x0000, 0x2000, CRC(2e134b46) SHA1(0938f5f9f5cc6d7c1096c569449db78dbc42da01) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "136014.152", 0x2000, 0x2000, CRC(a7e3a1c6) SHA1(b7340318afaa4b5f416fe4444899579242cd36c2) )
ROM_LOAD( "136014.154", 0x4000, 0x2000, CRC(8992d381) SHA1(3bf2544dbe88132137acec2c064a104a74139ec7) )
ROM_LOAD( "136014.151", 0x8000, 0x2000, CRC(6f9997d2) SHA1(b26d505266ccf23bfd867f881756c3251c80f57b) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "136014.153", 0xa000, 0x2000, CRC(6c5c6e68) SHA1(dce74ee0e69e0fc0a1942a489c2065381239f0f1) )
ROM_LOAD( "136014.155", 0xc000, 0x2000, CRC(111896ad) SHA1(15032b4c859231373bebfa640421fdcc8ba9d211) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "136014.158", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "136014.159", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "136014.134", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "136014.231", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "136014.137", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "136014.138", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "136014.139", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "136014.140", 0x0300, 0x0100, CRC(1e8d0491) SHA1(e8bf1db5c1fb04a35763099965cf5c588240bde5) ) /* alpha color */
ROM_LOAD( "136014.141", 0x0400, 0x0100, CRC(0e4fe8a0) SHA1(d330b1e5ebccf5bbefcf71486fd80d816de38196) ) /* background color */
ROM_LOAD( "136014.142", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "136014.143", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "136014.144", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "136014.145", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "136014.146", 0x0c00, 0x0400, CRC(ca4ba741) SHA1(de93d738bd27e24dbc4a8378d2c120ef8388c261) ) /* sprite color */
ROM_LOAD( "136014.135", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "136014.136", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "136014.118", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "136014.110", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "136014.111", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
ROM_REGION( 0x6000, "52xx", 0 )
ROM_LOAD( "136014.106", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "136014.117", 0x0000, 0x0100, CRC(2401c817) SHA1(8991b7994513a469e64392fa8f233af5e5f06d54) ) /* sync chain */
ROM_REGION( 0x0002, "cpu_pals", 0 ) /* PAL's located on the cpu board */
ROM_LOAD( "137316-001.2n", 0x0000, 0x0001, NO_DUMP ) /* MMI PAL16L6CN */
ROM_LOAD( "137316-00x.5c", 0x0000, 0x0001, NO_DUMP ) /* MMI PAL16L6CN */
ROM_END
/*
Top Racer / Pole Position I/II (?)
PCB Layouts
===========
Upper Board
-----------
PP-1126
|----------------------------------------------------------------------------------|
| LM324 8A 9A |
|1B DIP28 DIP28 DIP28 |
| 4066 |
| |
| LM324 |
| DSW2 4066 4066 |
| MB8841 MB8841 MB8841 82S129.14C |
| |
| |
| DSW1 |
| 4066 4066 82S153.16D |
| |
| |
| MB8842 |
| LM324 82S129.9E 2148 2148 Z80 Z8002 Z8002 |
| |-----daughterboard-------| |
| | | |
| | 82S153.18E 82S153.21E| |
| | 20E | |
| 6116| | |
| ADC0804 |16F 17F 20F 21F | 23F |
| |-------------------------| |
| 16F 17F |
| 4066 |
| |
| 4093 |
| 3.6V_BATT |
|---------|----18-way-----|-----------------J2-------|----50-pin cable---|---------|
|---------------| |-------------------|
Notes:
82S153 - Field Programmable Logic Array (DIP20)
2148 - 1K x4bit SRAM (DIP18)
6116 - 2K x8bit SRAM (DIP24)
ADC0804 - 8bit Microprocessor Compatible A/D Convertor (DIP20)
J2 - 3 Pin Power Connector
DIP28 - Unpopulated Sockets
MB8841 - Fujitsu 4bit Microcontroller (DIP40)
MB8842 - Fujitsu 4bit Microcontroller (DIP28)
LM324 - Low Power Quad Operational Amplifier (DIP14)
Note - All ROMs labelled PP2_U.* are located on the upper PCB.
All ROMs labelled PP2_D.* are located on the plug-in daughterboard.
Lower Board
-----------
|----------------------------------------------------------------------------------|
| 1A 2A 3A 4A 5A 6A 7A 8A 9A 10A |
| |
| 9D 82S129.13D |
| |
| 82S129.13E |
| 2148 2148 |
| 82S129.13F |
| 6116 6116 82S137.7H |
| |
| |
| |
| 2J 6116 6116 |
| |
| |
| |
| 2M 8M 9M |
| |
| |
| 82S129.2N |
| 2114 2114 |
| 82S129.2P 82S137.5P 8P |
| 2114 2114 82S123.15R |
| 82S129.2S |
| 2114 2114 82S123.15S |
| 82S129.2T |
| MB3730 MB3730 MB3730 MB3730 24.576MHz 2114 2114 |
| 82S129.2U VOL VOL VOL VOL |
| |
|---------|----18-way-----|-----------------J2-------|----50-pin cable---|---------|
|---------------| |-------------------|
Notes:
2114 - 1K x4bit SRAM (DIP18)
2148 - 1K x4bit SRAM (DIP18)
6116 - 2K x8bit SRAM (DIP24)
MB3730 - 12W Power Amp IC (SIP7)
J2 - 3 Pin Power Connector
VOL - Volume Potentiometer
Note - All ROMs labelled PP2_L.* are located on the lower PCB.
*/
ROM_START( topracer )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "pp1_9b.6h", 0x0000, 0x2000, CRC(94436b70) SHA1(7495c2a8c3928c59146760d19e672afee01c5b17) )
ROM_LOAD( "136014.116", 0x2000, 0x1000, CRC(7174bcb7) SHA1(460326a6cea201db2df813013c95562a222ea95d) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "tr1b.bin", 0x0001, 0x2000, CRC(127f0750) SHA1(97ae6c6f8086187c7cdb8bff5fec94914791890b) )
ROM_LOAD16_BYTE( "tr2b.bin", 0x0000, 0x2000, CRC(6bd4ff6b) SHA1(cf992de39a8cf7804961a8e6773fc4f7feb1878b) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "tr5b.bin", 0x0001, 0x2000, CRC(4e5f7b9c) SHA1(d26b1f24dd9ef00388987890bc5b95d4db403815) )
ROM_LOAD16_BYTE( "tr6b.bin", 0x0000, 0x2000, CRC(9d038ada) SHA1(7a9496c3fb93fd1945393656f8510a0c6421a9ab) )
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "tr28.bin", 0x0000, 0x1000, CRC(b8217c96) SHA1(aba311bc3c4b118ba322a00e33e2d5cbe7bc6e4a) )
ROM_REGION( 0x01000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "tr29.bin", 0x0000, 0x1000, CRC(c6e15c21) SHA1(e2a70b3f7ce51a003068eb75d9fe82548f0206d7) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "trus25.bin", 0x0000, 0x2000, CRC(9e1a9c3b) SHA1(deca026c39093119985d1486ed61abc3e6e5705c) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "trus26.bin", 0x2000, 0x2000, CRC(3b39a176) SHA1(d04c9c2c9129c8dd7d7eab24c43502b67162407c) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "pp17.bin", 0x0000, 0x2000, CRC(613ab0df) SHA1(88aa4500275aae010fc9783c1d8d843feab89afa) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "tr19.bin", 0x2000, 0x2000, CRC(f8e7f551) SHA1(faa23c55bc43325e6f71936be970f2ca144697d8) )
ROM_LOAD( "tr21.bin", 0x4000, 0x2000, CRC(17c798b0) SHA1(ae2047bc0e4e8c85e1de09c39c200ea8f7c6a72e) )
ROM_LOAD( "pp18.bin", 0x8000, 0x2000, CRC(5fd933e3) SHA1(5b27a8519234c935308f943cd58abc1efc463726) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "tr20.bin", 0xa000, 0x2000, CRC(7053e219) SHA1(97700fbe887e2d11c9f9a0937147725f6787f081) )
// ROM_LOAD( "tr22.bin", 0xc000, 0x2000, CRC(f48917b2) SHA1(2823cfc33ae97ef979d92e2eeeb94c95f1f3d9f3) ) /* differs by one bit, almost certainly bitrot */
ROM_LOAD( "tr22.bin", 0xc000, 0x2000, CRC(5fe9b365) SHA1(1a3ac099a6bb506a5f71c12c6fb14d014172371c) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "136014.158", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "136014.159", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "136014.134", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "136014.231", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "136014.137", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "136014.138", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "136014.139", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "7052-10.h15", 0x0300, 0x0100, CRC(5af3f710) SHA1(da13d17acf8abd0f6ebb4b51b23c3324c6197b7d) ) /* alpha color */
ROM_LOAD( "7052-11.j15", 0x0400, 0x0100, CRC(8c90e36e) SHA1(2646288d9e0f86300da7f06e1dc0595673205bb4) ) /* background color */
ROM_LOAD( "136014.142", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "136014.143", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "136014.144", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "136014.145", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "7122.e7", 0x0c00, 0x0400, CRC(2f1079ee) SHA1(18a27998a78deff13dd198f3668a7e92f084f467) ) /* sprite color */
ROM_LOAD( "136014.135", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "136014.136", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "136014.118", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "136014.110", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "136014.111", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
ROM_REGION( 0x6000, "52xx", 0 )
ROM_LOAD( "136014.106", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "7052-4.c14", 0x0000, 0x0100, CRC(0e742cb1) SHA1(3ae43270aab4848fdeece1648e7e040ab216b08e) ) /* sync chain */
ROM_END
ROM_START( topracera )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "tr9.f17", 0x0000, 0x2000, CRC(94436b70) SHA1(7495c2a8c3928c59146760d19e672afee01c5b17) )
ROM_LOAD( "tr10.f16", 0x2000, 0x1000, CRC(7174bcb7) SHA1(460326a6cea201db2df813013c95562a222ea95d) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "tr1b.f11", 0x0001, 0x2000, CRC(127f0750) SHA1(97ae6c6f8086187c7cdb8bff5fec94914791890b) )
ROM_LOAD16_BYTE( "tr2b.f8", 0x0000, 0x2000, CRC(6bd4ff6b) SHA1(cf992de39a8cf7804961a8e6773fc4f7feb1878b) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "tr5b.f7", 0x0001, 0x2000, CRC(4e5f7b9c) SHA1(d26b1f24dd9ef00388987890bc5b95d4db403815) )
ROM_LOAD16_BYTE( "tr6b.f5", 0x0000, 0x2000, CRC(b3641d0c) SHA1(38ce172b2e38895749cbd3cc1c0e2c0fe8be744a) )
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "tr28.j9", 0x0000, 0x1000, CRC(b8217c96) SHA1(aba311bc3c4b118ba322a00e33e2d5cbe7bc6e4a) )
ROM_REGION( 0x01000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "tr29.k9", 0x0000, 0x1000, CRC(c6e15c21) SHA1(e2a70b3f7ce51a003068eb75d9fe82548f0206d7) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "tr25.d5", 0x0000, 0x2000, CRC(9e1a9c3b) SHA1(deca026c39093119985d1486ed61abc3e6e5705c) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "tr26.d8", 0x2000, 0x2000, CRC(3b39a176) SHA1(d04c9c2c9129c8dd7d7eab24c43502b67162407c) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "tr17.a5", 0x0000, 0x2000, CRC(613ab0df) SHA1(88aa4500275aae010fc9783c1d8d843feab89afa) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "tr19.b5", 0x2000, 0x2000, CRC(f8e7f551) SHA1(faa23c55bc43325e6f71936be970f2ca144697d8) )
ROM_LOAD( "tr21.c5", 0x4000, 0x2000, CRC(17c798b0) SHA1(ae2047bc0e4e8c85e1de09c39c200ea8f7c6a72e) )
ROM_LOAD( "tr18.a8", 0x8000, 0x2000, CRC(5fd933e3) SHA1(5b27a8519234c935308f943cd58abc1efc463726) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "tr20.b8", 0xa000, 0x2000, CRC(7053e219) SHA1(97700fbe887e2d11c9f9a0937147725f6787f081) )
ROM_LOAD( "tr22.c8", 0xc000, 0x2000, CRC(5fe9b365) SHA1(1a3ac099a6bb506a5f71c12c6fb14d014172371c) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "tr30.b15", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "tr31.a15", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "tr32.c15", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "tr27.d3", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "7052-7.k21", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "7052-8.k20", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "7052-9.k19", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "7052-10.h15", 0x0300, 0x0100, CRC(5af3f710) SHA1(da13d17acf8abd0f6ebb4b51b23c3324c6197b7d) ) /* alpha color */
ROM_LOAD( "7052-11.j15", 0x0400, 0x0100, CRC(8c90e36e) SHA1(2646288d9e0f86300da7f06e1dc0595673205bb4) ) /* background color */
ROM_LOAD( "7052-15.d1", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "7052-16.d2", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "7052-17.d3", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "7122.a19", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "7122.e7", 0x0c00, 0x0400, CRC(2f1079ee) SHA1(18a27998a78deff13dd198f3668a7e92f084f467) ) /* sprite color */
ROM_LOAD( "7051-13.l7", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "7051-14.l8", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "7052-5.e9", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "tr15.a8", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "tr16.b9", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
ROM_REGION( 0x6000, "52xx", 0 )
ROM_LOAD( "tr11.b1", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "7052-4.c14", 0x0000, 0x0100, CRC(0e742cb1) SHA1(3ae43270aab4848fdeece1648e7e040ab216b08e) ) /* sync chain */
ROM_END
ROM_START( ppspeed )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "tr9b.bin", 0x0000, 0x2000, CRC(538bd0cb) SHA1(36a0628ce735c76e5db83d195af3a9bed5155c60) )
ROM_LOAD( "tr10.bin", 0x2000, 0x1000, CRC(7174bcb7) SHA1(460326a6cea201db2df813013c95562a222ea95d) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "tr1b.bin", 0x0001, 0x2000, CRC(127f0750) SHA1(97ae6c6f8086187c7cdb8bff5fec94914791890b) )
ROM_LOAD16_BYTE( "tr2b.bin", 0x0000, 0x2000, CRC(6bd4ff6b) SHA1(cf992de39a8cf7804961a8e6773fc4f7feb1878b) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "tr5b.bin", 0x0001, 0x2000, CRC(4e5f7b9c) SHA1(d26b1f24dd9ef00388987890bc5b95d4db403815) )
ROM_LOAD16_BYTE( "tr6b.bin", 0x0000, 0x2000, CRC(b3641d0c) SHA1(38ce172b2e38895749cbd3cc1c0e2c0fe8be744a) ) // sldh
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "tr28.bin", 0x0000, 0x1000, CRC(cd80b4c3) SHA1(5f237c1e7eb94ecb2680270afdf31c8e111164c5) ) // sldh
ROM_REGION( 0x01000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "tr29.bin", 0x0000, 0x1000, CRC(c6e15c21) SHA1(e2a70b3f7ce51a003068eb75d9fe82548f0206d7) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "tr25.bin", 0x0000, 0x2000, CRC(f44d33c1) SHA1(e09bcc127e61b351e99c54bf0e3cbab8583949ec) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "tr26.bin", 0x2000, 0x2000, CRC(87e8482d) SHA1(3f1c7f0f9b27e8b61e62db55dd4332c75dc31558) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "tr17.bin", 0x0000, 0x2000, CRC(613ab0df) SHA1(88aa4500275aae010fc9783c1d8d843feab89afa) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "tr19.bin", 0x2000, 0x2000, CRC(1ea04ccd) SHA1(1cec1e4d0f47365245d92489f78d3edd4f23481f) ) // sldh
ROM_LOAD( "tr21.bin", 0x4000, 0x2000, CRC(bd7b4a62) SHA1(66175a9382f627053097f0bc9a3fd49a26f8ac8f) ) // sldh
ROM_LOAD( "tr18.bin", 0x8000, 0x2000, CRC(5fd933e3) SHA1(5b27a8519234c935308f943cd58abc1efc463726) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "tr20.bin", 0xa000, 0x2000, CRC(c572c6ed) SHA1(c2398a82a57be92a0bdc58330504e821878492ea) ) // sldh
ROM_LOAD( "tr22.bin", 0xc000, 0x2000, CRC(db1bcdd8) SHA1(ffd4edd8c02914a0a85cd7e39153c27d79526457) ) // sldh
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "tr30.bin", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "tr31.bin", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "tr32.bin", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "tr27.bin", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "tr15.bin", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "tr16.bin", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
// nothing below was verified on this boardset, assumed to be the same
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "7052-7.k21", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "7052-8.k20", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "7052-9.k19", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "7052-10.h15", 0x0300, 0x0100, CRC(5af3f710) SHA1(da13d17acf8abd0f6ebb4b51b23c3324c6197b7d) ) /* alpha color */
ROM_LOAD( "7052-11.j15", 0x0400, 0x0100, CRC(8c90e36e) SHA1(2646288d9e0f86300da7f06e1dc0595673205bb4) ) /* background color */
ROM_LOAD( "7052-15.d1", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "7052-16.d2", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "7052-17.d3", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "7122.a19", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "7122.e7", 0x0c00, 0x0400, CRC(2f1079ee) SHA1(18a27998a78deff13dd198f3668a7e92f084f467) ) /* sprite color */
ROM_LOAD( "7051-13.l7", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "7051-14.l8", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "7052-5.e9", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x6000, "52xx", 0 )
ROM_LOAD( "tr11.b1", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "7052-4.c14", 0x0000, 0x0100, CRC(0e742cb1) SHA1(3ae43270aab4848fdeece1648e7e040ab216b08e) ) /* sync chain */
ROM_END
/* Top Racer (bootleg without MB8841 / MB8842)
CPU Lower Board (label "1081-C")
2x ZILOG Z8002PS (DIP40)
1x NEC D708C-1 (DIP40)
Upper Board (label "1080-C")
1x oscillator 24.576 MHz
ROMs Lower Board (label "1081-C")
7x HN482764G (1a,a2,a3,a4,a5,a,b)
1x HN482732G (a6)
1x PROM 82S129
2x PAL 12L6
1x PAL 16L8
Upper Board (label "1080-C")
8x HN482764G (1,2,3,6,7,8,9,10)
2x AM2764 (5,11)
4x TMS2732JL (12,13,14,15)
8x PROM 24S10
2x PROM 7603
2x PROM 7643
Note Lower Board (label "1081-C")
1x flat cable connector to upper
1x 18x2 edge connector
Upper Board (label "1080-C")
1x flat cable connector to lower
1x 18x2 edge connector
*/
ROM_START( topracern )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "a5.bin", 0x0000, 0x2000, CRC(caab829a) SHA1(826f25f5c792ab8b24e73ebb735aebcad552454f) )
ROM_LOAD( "a6.bin", 0x2000, 0x1000, CRC(148f5000) SHA1(071f75518f06a317f53db78f11da3ee878569f86) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "a1.bin", 0x0001, 0x2000, CRC(127f0750) SHA1(97ae6c6f8086187c7cdb8bff5fec94914791890b) )
ROM_LOAD16_BYTE( "a2.bin", 0x0000, 0x2000, CRC(6bd4ff6b) SHA1(cf992de39a8cf7804961a8e6773fc4f7feb1878b) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "a3.bin", 0x0001, 0x2000, CRC(4e5f7b9c) SHA1(d26b1f24dd9ef00388987890bc5b95d4db403815) )
//ROM_LOAD16_BYTE( "a4.bin", 0x0000, 0x2000, CRC(b3641d0c) SHA1(38ce172b2e38895749cbd3cc1c0e2c0fe8be744a) ) /* one set had this rom, which matches topracera */
ROM_LOAD16_BYTE( "pole-d", 0x0000, 0x2000, CRC(932bb5a7) SHA1(8045fe1f9b4b1973ec0d6705adf3ba3891bddaa1) ) /* the other set had this one, what's the difference? */
/* graphics data */
ROM_REGION( 0x01000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "13.bin", 0x0000, 0x1000, CRC(b8217c96) SHA1(aba311bc3c4b118ba322a00e33e2d5cbe7bc6e4a) )
ROM_REGION( 0x01000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "12.bin", 0x0000, 0x1000, CRC(c6e15c21) SHA1(e2a70b3f7ce51a003068eb75d9fe82548f0206d7) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "5.bin", 0x0000, 0x2000, CRC(301117d2) SHA1(0d8be9e50da4601963a8392aa3e0f3414e721fa1) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "6.bin", 0x2000, 0x2000, CRC(3c9db014) SHA1(c26098dd78803e699845fefa92bf034c38259cea) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "1.bin", 0x0000, 0x2000, CRC(613ab0df) SHA1(88aa4500275aae010fc9783c1d8d843feab89afa) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "2.bin", 0x2000, 0x2000, CRC(f8e7f551) SHA1(faa23c55bc43325e6f71936be970f2ca144697d8) )
//ROM_LOAD( "3.bin", 0x4000, 0x2000, CRC(94d0b00c) SHA1(24e4004d1091292afda76bdfb007f08c13778675) ) // this one has more corrupt lines in one of the flags
ROM_LOAD( "3.bin", 0x4000, 0x2000, CRC(17c798b0) SHA1(ae2047bc0e4e8c85e1de09c39c200ea8f7c6a72e) )
ROM_LOAD( "7.bin", 0x8000, 0x2000, CRC(5fd933e3) SHA1(5b27a8519234c935308f943cd58abc1efc463726) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "8.bin", 0xa000, 0x2000, CRC(7053e219) SHA1(97700fbe887e2d11c9f9a0937147725f6787f081) )
ROM_LOAD( "9.bin", 0xc000, 0x2000, CRC(5fe9b365) SHA1(1a3ac099a6bb506a5f71c12c6fb14d014172371c) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "11.bin", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "10.bin", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "14.bin", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "15.bin", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "24s10.5", 0x0000, 0x0100, CRC(f07ff2ad) SHA1(e1f3cb10a03d23f8c1d422acf271dba4e7b98cb1) ) /* red palette */
ROM_LOAD( "24s10.4", 0x0100, 0x0100, CRC(adbde7d7) SHA1(956ac5117c1e310f554ac705aa2dc24a796c36a5) ) /* green palette */
ROM_LOAD( "24s10.3", 0x0200, 0x0100, CRC(ddac786a) SHA1(d1860105bf91297533ccc4aa6775987df198d0fa) ) /* blue palette */
ROM_LOAD( "24s10.2", 0x0300, 0x0100, CRC(5af3f710) SHA1(da13d17acf8abd0f6ebb4b51b23c3324c6197b7d) ) /* alpha color */
ROM_LOAD( "24s10.1", 0x0400, 0x0100, CRC(8c90e36e) SHA1(2646288d9e0f86300da7f06e1dc0595673205bb4) ) /* background color */
ROM_LOAD( "24s10.8", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "24s10.7", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "24s10.6", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "7643.1", 0x0800, 0x0400, CRC(7afc7cfc) SHA1(ba2407f6eff124e881b354f13205a4c058b7cf60) ) /* road color */
ROM_LOAD( "7643.2", 0x0c00, 0x0400, CRC(2f1079ee) SHA1(18a27998a78deff13dd198f3668a7e92f084f467) ) /* sprite color */
ROM_LOAD( "7603.1", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "7603.2", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "136014.118", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "a.bin", 0x0000, 0x2000, CRC(b5ad4d5f) SHA1(c07e77a050200d6fe9952031f971ca35f4d15ff8) ) /* engine sound */
ROM_LOAD( "b.bin", 0x2000, 0x2000, CRC(8fdd2f6f) SHA1(3818dc94c60cd78c4212ab7a4367cf3d98166ee6) ) /* engine sound */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "7052-4.c14", 0x0000, 0x0100, CRC(0e742cb1) SHA1(3ae43270aab4848fdeece1648e7e040ab216b08e) ) /* sync chain */
ROM_END
/*
Pole Position 2 - Namco Version
*/
ROM_START( polepos2 )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "pp4_9.6h", 0x0000, 0x2000, CRC(bcf87004) SHA1(0c60cbb777fe72dfd11c6f3e9da806a515cd0f8a) )
ROM_LOAD( "pp4_10.5h", 0x2000, 0x1000, CRC(a9d4c380) SHA1(6048a8e858824936901e8e3e6b65d7505ccd82b4) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "pp4_1.8m", 0x0001, 0x2000, CRC(3f6ac294) SHA1(414ea7e43e62a573ad8971a7045f61eb997cf94e) )
ROM_LOAD16_BYTE( "pp4_2.8l", 0x0000, 0x2000, CRC(51b9a669) SHA1(563ba42098d330801a992cd9c008c4cbbb993530) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "pp4_5.4m", 0x0001, 0x2000, CRC(c3053cae) SHA1(f42cf61fe696dd7e282b29e2234ea7f487ec2372) )
ROM_LOAD16_BYTE( "pp4_6.4l", 0x0000, 0x2000, CRC(38d04e0f) SHA1(5527cb1864248208b10d219a50ad742f286a119f) )
ROM_LOAD16_BYTE( "pp4_7.3m", 0x4001, 0x1000, CRC(ad1c8994) SHA1(2877de9641516767170c0109900955cc7d1ff402) )
ROM_LOAD16_BYTE( "pp4_8.3l", 0x4000, 0x1000, CRC(ef25a2ee) SHA1(45959355cad1a48f19ae14193374e03d4f9965c7) )
/* graphics data */
ROM_REGION( 0x02000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "pp4_28.1f", 0x0000, 0x2000, CRC(280dde7d) SHA1(b7c7fb3a5076aa4d0e0cf3256ece9a6194315626) )
ROM_REGION( 0x02000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "pp4_29.1e", 0x0000, 0x2000, CRC(ec3ec6e6) SHA1(ae905d0ae802d1010b2c1f1a13e88a1f0dbe57da) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "pp4_25.1n", 0x0000, 0x2000, CRC(fd098e65) SHA1(2c497f1d278ba6730752706a0d1b5a5a0fec3d5b) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "pp4_26.1m", 0x2000, 0x2000, CRC(35ac62b3) SHA1(21038a78eb73d520e3e1ae8e1c0047d06b94cdab) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "pp1_17.5n", 0x0000, 0x2000, CRC(2e134b46) SHA1(0938f5f9f5cc6d7c1096c569449db78dbc42da01) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "pp1_19.4n", 0x2000, 0x2000, CRC(43ff83e1) SHA1(8f830549a629b019125e59801e5027e4e4b3c0f2) )
ROM_LOAD( "pp1_21.3n", 0x4000, 0x2000, CRC(5f958eb4) SHA1(b56d84e5e5e0ddeb0e71851ba66e5fa1b1409551) )
ROM_LOAD( "pp4_23.2n", 0x6000, 0x2000, CRC(9e056fcd) SHA1(8545e0a9b6ebf8c2903321ceb9c4d693db10d750) )
ROM_LOAD( "pp1_18.5m", 0x8000, 0x2000, CRC(6f9997d2) SHA1(b26d505266ccf23bfd867f881756c3251c80f57b) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "pp1_20.4m", 0xa000, 0x2000, CRC(ec18075b) SHA1(af7be549c5fa47551a8dca4c0a531552147fa50f) )
ROM_LOAD( "pp1_22.3m", 0xc000, 0x2000, CRC(1d2f30b1) SHA1(1d88a3069e9b15febd2835dd63e5511b3b2a6b45) )
ROM_LOAD( "pp4_24.2m", 0xe000, 0x2000, CRC(795268cf) SHA1(84136142ef4bdcd97ede2209ecb16745960ac393) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "pp1_30.3a", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "pp1_31.2a", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "pp1_32.1a", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "pp1_27.1l", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "pp4-7.8l", 0x0000, 0x0100, CRC(16d69c31) SHA1(f24b345448e4f4ef4e2f3b057b81d399cf427f88) ) /* red palette */
ROM_LOAD( "pp4-8.9l", 0x0100, 0x0100, CRC(07340311) SHA1(3820d1fa99013ed18de5d9400ad376cc446d1217) ) /* green palette */
ROM_LOAD( "pp4-9.10l", 0x0200, 0x0100, CRC(1efc84d7) SHA1(6946e1c209eec0a4b75778ae88111e6cb63c63fb) ) /* blue palette */
ROM_LOAD( "pp4-10.2h", 0x0300, 0x0100, CRC(064d51a0) SHA1(d5baa29930530a8930b44a374e285de849c2a6ce) ) /* alpha color */
ROM_LOAD( "pp4-11.4d", 0x0400, 0x0100, CRC(7880c5af) SHA1(e4388e354420be3f99594a10c091e3d2f745cc04) ) /* background color */
ROM_LOAD( "pp1-15.9a", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "pp1-16.10a", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "pp1-17.11a", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "pp4-12.3c", 0x0800, 0x0400, CRC(8b270902) SHA1(27b3ebc92d3a2a5c0432bde018a0e43669041d50) ) /* road color */
ROM_LOAD( "pp4-6.6m", 0x0c00, 0x0400, CRC(647212b5) SHA1(ad58dfebd0ce8226285c2671c3b7797852c26d07) ) /* sprite color */
ROM_LOAD( "pp1-13.8e", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "pp1-14.9e", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "pp1-5.3b", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "pp4_15.6a", 0x0000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_LOAD( "pp4_16.5a", 0x2000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_REGION( 0x8000, "52xx", 0 )
ROM_LOAD( "pp1_11.2e", 0x0000, 0x2000, CRC(45b9bfeb) SHA1(ff8c690471944d414931fb88666594ef608997f8) ) /* voice */
ROM_LOAD( "pp1_12.2f", 0x2000, 0x2000, CRC(a31b4be5) SHA1(38298093bb97ea8647fe187359cae05b65e1c616) ) /* voice */
ROM_LOAD( "pp1_13.1e", 0x4000, 0x2000, CRC(a4237466) SHA1(88a397276038cc2fc05f2c18472e6b7cef167f2e) ) /* voice */
ROM_LOAD( "pp1_14.1f", 0x6000, 0x2000, CRC(944580f9) SHA1(c76f529cae718674ce97a1a599a3c6eaf6bf561a) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "pp1-4.9h", 0x0000, 0x0100, CRC(2401c817) SHA1(8991b7994513a469e64392fa8f233af5e5f06d54) ) /* sync chain */
ROM_END
/*
Pole Position 2 - Atari Version
CPU/Sound Board: A039185
Video Board: A039187
Pole Position 2 uses the same hardware as Pole Position except there a
couple of extra roms.
*/
ROM_START( polepos2a )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "136014.180", 0x0000, 0x2000, CRC(f85212c4) SHA1(666e55a7662247e72393b105b3e719be4233f1ff) )
ROM_LOAD( "136014.183", 0x2000, 0x1000, CRC(a9d4c380) SHA1(6048a8e858824936901e8e3e6b65d7505ccd82b4) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "136014.176", 0x0001, 0x2000, CRC(8aeaec98) SHA1(76b3bbb64a17090bf28858f1e91d2206a3beaf5b) )
ROM_LOAD16_BYTE( "136014.177", 0x0000, 0x2000, CRC(7051df35) SHA1(cf23118ab05f5af273d756f97e6453496a276c9a) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "136014.178", 0x0001, 0x2000, CRC(eac35cfa) SHA1(f96005b3b63d85fc30695ab746af79c60f2f1341) )
ROM_LOAD16_BYTE( "136014.179", 0x0000, 0x2000, CRC(613e917d) SHA1(97c139f8aa7bd871a907e72980757b83f99fd8a0) )
ROM_LOAD16_BYTE( "136014.184", 0x4001, 0x2000, CRC(d893c4ed) SHA1(60d39abefbb0c8df68864a30b1f5fcbf4780c86c) )
ROM_LOAD16_BYTE( "136014.185", 0x4000, 0x2000, CRC(899de75e) SHA1(4a16535115e37a3d342b2cb53f610a87c0d0abe1) )
/* graphics data */
ROM_REGION( 0x02000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "136014.172", 0x0000, 0x2000, CRC(fbe5e72f) SHA1(07965d6e98ac1332ac6192b5e9cc927dd9eb706f) )
ROM_REGION( 0x02000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "136014.173", 0x0000, 0x2000, CRC(ec3ec6e6) SHA1(ae905d0ae802d1010b2c1f1a13e88a1f0dbe57da) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "136014.170", 0x0000, 0x2000, CRC(455d79a0) SHA1(03ef7c58f3145d9a6a461ef1aea3b5a49e653f80) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "136014.171", 0x2000, 0x2000, CRC(78372b81) SHA1(5defaf2074c1ab4d13dc36a190c658ddf7f7931b) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "136014.119", 0x0000, 0x2000, CRC(2e134b46) SHA1(0938f5f9f5cc6d7c1096c569449db78dbc42da01) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "136014.166", 0x2000, 0x2000, CRC(2b0517bd) SHA1(ebe447ba3dcd8a3b56f47d707483074f61953fec) )
ROM_LOAD( "136014.168", 0x4000, 0x2000, CRC(4d7916d9) SHA1(052745f252f51bfdd456e54cf7b8d22ab3aace27) )
ROM_LOAD( "136014.175", 0x6000, 0x2000, CRC(bd6df480) SHA1(58f39fa3ae43d94fe42dc51da341384a9c3879ae) )
ROM_LOAD( "136014.120", 0x8000, 0x2000, CRC(6f9997d2) SHA1(b26d505266ccf23bfd867f881756c3251c80f57b) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "136014.167", 0xa000, 0x2000, CRC(411e21b5) SHA1(9659ee429d819926b5e5b12c41b968ae6e7f186e) )
ROM_LOAD( "136014.169", 0xc000, 0x2000, CRC(662ff24b) SHA1(4cf8509034742c2bec8a96c7a786dafdf5875e4f) )
ROM_LOAD( "136014.174", 0xe000, 0x2000, CRC(f0c571dc) SHA1(9e6839e9e203fc120a0389f4e11c9d46a817dbdf) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "136014.127", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "136014.128", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "136014.134", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "136014.231", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "136014.186", 0x0000, 0x0100, CRC(16d69c31) SHA1(f24b345448e4f4ef4e2f3b057b81d399cf427f88) ) /* red palette */
ROM_LOAD( "136014.187", 0x0100, 0x0100, CRC(07340311) SHA1(3820d1fa99013ed18de5d9400ad376cc446d1217) ) /* green palette */
ROM_LOAD( "136014.188", 0x0200, 0x0100, CRC(1efc84d7) SHA1(6946e1c209eec0a4b75778ae88111e6cb63c63fb) ) /* blue palette */
ROM_LOAD( "136014.189", 0x0300, 0x0100, CRC(064d51a0) SHA1(d5baa29930530a8930b44a374e285de849c2a6ce) ) /* alpha color */
ROM_LOAD( "136014.190", 0x0400, 0x0100, CRC(7880c5af) SHA1(e4388e354420be3f99594a10c091e3d2f745cc04) ) /* background color */
ROM_LOAD( "136014.142", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "136014.143", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "136014.144", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "136014.191", 0x0800, 0x0400, CRC(8b270902) SHA1(27b3ebc92d3a2a5c0432bde018a0e43669041d50) ) /* road color */
ROM_LOAD( "136014.192", 0x0c00, 0x0400, CRC(caddb0b0) SHA1(e41b89f2b40bf8f93546012f373ae63dcae870da) ) /* sprite color */
ROM_LOAD( "136014.135", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "136014.136", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "136014.118", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "136014.181", 0x0000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_LOAD( "136014.182", 0x2000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_REGION( 0x6000, "52xx", 0 )
ROM_LOAD( "136014.106", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "136014.117", 0x0000, 0x0100, CRC(2401c817) SHA1(8991b7994513a469e64392fa8f233af5e5f06d54) ) /* sync chain */
ROM_REGION( 0x0002, "cpu_pals", 0 ) /* PAL's located on the cpu board */
ROM_LOAD( "137316-001.2n", 0x0000, 0x0001, NO_DUMP ) /* MMI PAL16L6CN */
ROM_LOAD( "137316-00x.5c", 0x0000, 0x0001, NO_DUMP ) /* MMI PAL16L6CN */
ROM_END
ROM_START( polepos2b )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "136014.180", 0x0000, 0x2000, CRC(f85212c4) SHA1(666e55a7662247e72393b105b3e719be4233f1ff) )
ROM_LOAD( "136014.183", 0x2000, 0x1000, CRC(a9d4c380) SHA1(6048a8e858824936901e8e3e6b65d7505ccd82b4) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "3lcpu.rom", 0x0001, 0x2000, CRC(cf95a6b7) SHA1(6a8419af8a52d3a8c88663b67845e4cb18e35723) )
ROM_LOAD16_BYTE( "4lcpu.rom", 0x0000, 0x2000, CRC(643483f7) SHA1(020822f623b8e65c6016492266b6e328f7637b68) )
ROM_LOAD16_BYTE( "cpu-4k.rom", 0x4000, 0x1000, CRC(97a496b3) SHA1(fe79d2376c5fa9fe242905a841a1c894a5ccfba4) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "136014.178", 0x0001, 0x2000, CRC(eac35cfa) SHA1(f96005b3b63d85fc30695ab746af79c60f2f1341) )
ROM_LOAD16_BYTE( "136014.179", 0x0000, 0x2000, CRC(613e917d) SHA1(97c139f8aa7bd871a907e72980757b83f99fd8a0) )
ROM_LOAD16_BYTE( "136014.184", 0x4001, 0x2000, CRC(d893c4ed) SHA1(60d39abefbb0c8df68864a30b1f5fcbf4780c86c) )
ROM_LOAD16_BYTE( "136014.185", 0x4000, 0x2000, CRC(899de75e) SHA1(4a16535115e37a3d342b2cb53f610a87c0d0abe1) )
/* graphics data */
ROM_REGION( 0x02000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "136014.172", 0x0000, 0x2000, CRC(fbe5e72f) SHA1(07965d6e98ac1332ac6192b5e9cc927dd9eb706f) )
ROM_REGION( 0x02000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "136014.173", 0x0000, 0x2000, CRC(ec3ec6e6) SHA1(ae905d0ae802d1010b2c1f1a13e88a1f0dbe57da) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "136014.170", 0x0000, 0x2000, CRC(455d79a0) SHA1(03ef7c58f3145d9a6a461ef1aea3b5a49e653f80) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "136014.171", 0x2000, 0x2000, CRC(78372b81) SHA1(5defaf2074c1ab4d13dc36a190c658ddf7f7931b) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "136014.119", 0x0000, 0x2000, CRC(2e134b46) SHA1(0938f5f9f5cc6d7c1096c569449db78dbc42da01) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "136014.166", 0x2000, 0x2000, CRC(2b0517bd) SHA1(ebe447ba3dcd8a3b56f47d707483074f61953fec) )
ROM_LOAD( "136014.168", 0x4000, 0x2000, CRC(4d7916d9) SHA1(052745f252f51bfdd456e54cf7b8d22ab3aace27) )
ROM_LOAD( "136014.175", 0x6000, 0x2000, CRC(bd6df480) SHA1(58f39fa3ae43d94fe42dc51da341384a9c3879ae) )
ROM_LOAD( "136014.120", 0x8000, 0x2000, CRC(6f9997d2) SHA1(b26d505266ccf23bfd867f881756c3251c80f57b) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "136014.167", 0xa000, 0x2000, CRC(411e21b5) SHA1(9659ee429d819926b5e5b12c41b968ae6e7f186e) )
ROM_LOAD( "136014.169", 0xc000, 0x2000, CRC(662ff24b) SHA1(4cf8509034742c2bec8a96c7a786dafdf5875e4f) )
ROM_LOAD( "136014.174", 0xe000, 0x2000, CRC(f0c571dc) SHA1(9e6839e9e203fc120a0389f4e11c9d46a817dbdf) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "136014.127", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "136014.128", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "136014.134", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "136014.231", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "136014.186", 0x0000, 0x0100, CRC(16d69c31) SHA1(f24b345448e4f4ef4e2f3b057b81d399cf427f88) ) /* red palette */
ROM_LOAD( "136014.187", 0x0100, 0x0100, CRC(07340311) SHA1(3820d1fa99013ed18de5d9400ad376cc446d1217) ) /* green palette */
ROM_LOAD( "136014.188", 0x0200, 0x0100, CRC(1efc84d7) SHA1(6946e1c209eec0a4b75778ae88111e6cb63c63fb) ) /* blue palette */
ROM_LOAD( "136014.189", 0x0300, 0x0100, CRC(064d51a0) SHA1(d5baa29930530a8930b44a374e285de849c2a6ce) ) /* alpha color */
ROM_LOAD( "136014.190", 0x0400, 0x0100, CRC(7880c5af) SHA1(e4388e354420be3f99594a10c091e3d2f745cc04) ) /* background color */
ROM_LOAD( "136014.142", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "136014.143", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "136014.144", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "136014.191", 0x0800, 0x0400, CRC(8b270902) SHA1(27b3ebc92d3a2a5c0432bde018a0e43669041d50) ) /* road color */
ROM_LOAD( "136014.192", 0x0c00, 0x0400, CRC(caddb0b0) SHA1(e41b89f2b40bf8f93546012f373ae63dcae870da) ) /* sprite color */
ROM_LOAD( "136014.135", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "136014.136", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "136014.118", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
ROM_LOAD( "136014.181", 0x0000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_LOAD( "136014.182", 0x2000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_REGION( 0x6000, "52xx", 0 )
ROM_LOAD( "136014.106", 0x0000, 0x2000, CRC(5b4cf05e) SHA1(52342572940489175607bbf5b6cfd05ee9b0f004) ) /* voice */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "136014.117", 0x0000, 0x0100, CRC(2401c817) SHA1(8991b7994513a469e64392fa8f233af5e5f06d54) ) /* sync chain */
ROM_END
ROM_START( polepos2bi )
/* Z80 memory/ROM data */
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "5ita.bin", 0x0000, 0x2000, CRC(1a6412a1) SHA1(ccc41e60aad6ed332f8f2582860e11f10937dffa) )
ROM_LOAD( "6ita.bin", 0x2000, 0x1000, CRC(e7362148) SHA1(5a4ab037fa6a773b90c10ac4c4e9417183e0cfd8) )
/* Z8002 #1 memory/ROM data */
ROM_REGION( 0x10000, "sub", 0 )
ROM_LOAD16_BYTE( "19.bin", 0x0001, 0x2000, CRC(41da3c28) SHA1(c9294d686282adfc72796511c3c9e186ad057374) )
ROM_LOAD16_BYTE( "18.bin", 0x0000, 0x2000, CRC(2856d5b1) SHA1(96f5c3d67901a1abceca12b3448f381cc4852a33) )
/* Z8002 #2 memory/ROM data */
ROM_REGION( 0x10000, "sub2", 0 )
ROM_LOAD16_BYTE( "17.bin", 0x0001, 0x4000, CRC(6c823932) SHA1(68ef9f70c4305c3a3bacf83a64b727fd3711f34f) )
ROM_LOAD16_BYTE( "4.bin", 0x0000, 0x4000, CRC(fe9baeb6) SHA1(9a8ad2d8a69b4005f7abed278093fd57b9242bca) )
/* graphics data */
ROM_REGION( 0x02000, "gfx1", 0 ) /* 2bpp alpha layer */
ROM_LOAD( "05.bin", 0x0000, 0x2000, CRC(55bec6f3) SHA1(8b405c74473abb7debaa9114991e7b134d06fe42) )
ROM_REGION( 0x02000, "gfx2", 0 ) /* 2bpp view layer */
ROM_LOAD( "04.bin", 0x0000, 0x2000, CRC(ec3ec6e6) SHA1(ae905d0ae802d1010b2c1f1a13e88a1f0dbe57da) )
ROM_REGION( 0x04000, "gfx3", 0 ) /* 4bpp 16x16 sprites */
ROM_LOAD( "12.bin", 0x0000, 0x2000, CRC(1c72041a) SHA1(b65b09c4251ee61d247f359615e7adc7c80bc8d5) ) /* 4bpp sm sprites, planes 0+1 */
ROM_LOAD( "11.bin", 0x2000, 0x2000, CRC(1b38b257) SHA1(c7eec0692a31e1c8285bd1cba3ebd17ab253d2c9) ) /* 4bpp sm sprites, planes 2+3 */
ROM_REGION( 0x10000, "gfx4", 0 ) /* 4bpp 32x32 sprites */
ROM_LOAD( "16.bin", 0x0000, 0x2000, CRC(613ab0df) SHA1(88aa4500275aae010fc9783c1d8d843feab89afa) ) /* 4bpp lg sprites, planes 0+1 */
ROM_LOAD( "15.bin", 0x2000, 0x2000, CRC(f8e7f551) SHA1(faa23c55bc43325e6f71936be970f2ca144697d8) )
ROM_LOAD( "14.bin", 0x4000, 0x2000, CRC(17c798b0) SHA1(ae2047bc0e4e8c85e1de09c39c200ea8f7c6a72e) )
ROM_LOAD( "13.bin", 0x6000, 0x2000, CRC(ed6a8052) SHA1(dedd6d63f9a06a1edd57cb134e86c048cff7a3c1) )
ROM_LOAD( "10.bin", 0x8000, 0x2000, CRC(5fd933e3) SHA1(5b27a8519234c935308f943cd58abc1efc463726) ) /* 4bpp lg sprites, planes 2+3 */
ROM_LOAD( "09.bin", 0xa000, 0x2000, CRC(7053e219) SHA1(97700fbe887e2d11c9f9a0937147725f6787f081) )
ROM_LOAD( "08.bin", 0xc000, 0x2000, CRC(5fe9b365) SHA1(1a3ac099a6bb506a5f71c12c6fb14d014172371c) )
ROM_LOAD( "07.bin", 0xe000, 0x2000, CRC(ca14ca7b) SHA1(e58e40fdf1385ae9b080225d9ffe3ec5b122bf69) )
ROM_REGION( 0x5000, "gfx5", 0 ) /* road generation ROMs needed at runtime */
ROM_LOAD( "03.bin", 0x0000, 0x2000, CRC(ee6b3315) SHA1(9cc26c6d3604c0f60d716f86e67e9d9c0487f87d) ) /* road control */
ROM_LOAD( "02.bin", 0x2000, 0x2000, CRC(6d1e7042) SHA1(90113ff0c93ed86d95067290088705bb5e6608d1) ) /* road bits 1 */
ROM_LOAD( "01.bin", 0x4000, 0x1000, CRC(4e97f101) SHA1(f377d053821c74aee93ebcd30a4d43e6156f3cfe) ) /* road bits 2 */
ROM_REGION( 0x1000, "gfx6", 0 ) /* sprite scaling */
ROM_LOAD( "06.bin", 0x0000, 0x1000, CRC(a61bff15) SHA1(f7a59970831cdaaa7bf59c2221a38e4746c54244) ) /* vertical scaling */
/* graphics (P)ROM data */
ROM_REGION( 0x1040, "proms", 0 )
ROM_LOAD( "7611-5-e.bin", 0x0000, 0x0100, CRC(16d69c31) SHA1(f24b345448e4f4ef4e2f3b057b81d399cf427f88) ) /* red palette */
ROM_LOAD( "7611-5-d.bin", 0x0100, 0x0100, CRC(07340311) SHA1(3820d1fa99013ed18de5d9400ad376cc446d1217) ) /* green palette */
ROM_LOAD( "7611-5-c.bin", 0x0200, 0x0100, CRC(1efc84d7) SHA1(6946e1c209eec0a4b75778ae88111e6cb63c63fb) ) /* blue palette */
ROM_LOAD( "7611-5-b.bin", 0x0300, 0x0100, CRC(064d51a0) SHA1(d5baa29930530a8930b44a374e285de849c2a6ce) ) /* alpha color */
ROM_LOAD( "7611-5-a.bin", 0x0400, 0x0100, CRC(7880c5af) SHA1(e4388e354420be3f99594a10c091e3d2f745cc04) ) /* background color */
ROM_LOAD( "7611-5-h.bin", 0x0500, 0x0100, CRC(2d502464) SHA1(682b7dd22e51d5db52c0804b7e27e47641dfa6bd) ) /* vertical position low */
ROM_LOAD( "7611-5-g.bin", 0x0600, 0x0100, CRC(027aa62c) SHA1(c7030d8b64b80e107c446f6fbdd63f560c0a91c0) ) /* vertical position med */
ROM_LOAD( "7611-5-f.bin", 0x0700, 0x0100, CRC(1f8d0df3) SHA1(b8f17758f114f5e247b65b3f2922ca2660757e66) ) /* vertical position hi */
ROM_LOAD( "7643-5-b.bin", 0x0800, 0x0400, CRC(8b270902) SHA1(27b3ebc92d3a2a5c0432bde018a0e43669041d50) ) /* road color */
ROM_LOAD( "7643-5-a.bin", 0x0c00, 0x0400, CRC(a079ed19) SHA1(134b3d156a1ed0fa21cc5dc3cc84ea16ef7f84f7) ) /* sprite color - bad?*/
ROM_LOAD( "6331-1-b.bin", 0x1000, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
ROM_LOAD( "6331-1-a.bin", 0x1020, 0x0020, CRC(4330a51b) SHA1(9531d18ce2de4eda9913d47ef8c5cd8f05791716) ) /* video RAM address decoder (not used) */
/* sound (P)ROM data */
ROM_REGION( 0x0100, "namco", 0 )
ROM_LOAD( "74s287-b.bin", 0x0000, 0x0100, CRC(8568decc) SHA1(0aac1fa082858d4d201e21511c609a989f9a1535) ) /* Namco sound */
ROM_REGION( 0x4000, "engine", 0 )
// ROM_LOAD( "pp4-15.bin", 0x0000, 0x2000, CRC(5d79e1ad) SHA1(0323bdf3b9aca298b788bb07020653a43114c952) ) /* differs by one bit, almost certainly bitrot */
ROM_LOAD( "pp4-15.bin", 0x0000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_LOAD( "pp4-16.bin", 0x2000, 0x2000, CRC(7d93bc1c) SHA1(dad7c0aa24aef593c84e21f7f8858ca7ada86364) ) /* engine sound */
ROM_REGION( 0x6000, "52xx", ROMREGION_ERASEFF )
/* the bootleg has a TMS5220, NOT the Namco 52xx */
/* unknown or unused (P)ROM data */
ROM_REGION( 0x0100, "user1", 0 )
ROM_LOAD( "74s287-a.bin", 0x0000, 0x0100, CRC(0e742cb1) SHA1(3ae43270aab4848fdeece1648e7e040ab216b08e) ) /* sync chain */
/* this is used for the italian speech with a TMS5220, not properly hooked up */
ROM_REGION( 0x2000, "soundz80bl", 0 )
ROM_LOAD( "20.bin", 0x0000, 0x2000, CRC(1771fe1b) SHA1(da74ca85dfd4f5ad5a9dbfe6f7668d93105e3575) )
ROM_REGION( 0x2000, "pals", 0 )
ROM_LOAD( "pal12l6-a.bin.bad.dump", 0x0000, 0x34, BAD_DUMP CRC(56c2e02f) SHA1(33545f83d63b476d9164472b439aa7002506b33d) )
ROM_LOAD( "pal12l6-b.bin.bad.dump", 0x0000, 0x34, BAD_DUMP CRC(56c2e02f) SHA1(33545f83d63b476d9164472b439aa7002506b33d) )
ROM_LOAD( "pal16l8.bin.bad.dump", 0x0000,0x104, BAD_DUMP CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
ROM_END
/*********************************************************************
* Initialization routines
*********************************************************************/
DRIVER_INIT_MEMBER(polepos_state,topracern)
{
/* extra direct mapped inputs read */
m_maincpu->space(AS_IO).install_read_port(0x02, 0x02, "STEER");
m_maincpu->space(AS_IO).install_read_port(0x03, 0x03, "IN0");
m_maincpu->space(AS_IO).install_read_port(0x04, 0x04, "DSWA");
}
DRIVER_INIT_MEMBER(polepos_state,polepos2)
{
/* note that the bootleg version doesn't need this custom IC; it has a hacked ROM in its place */
m_subcpu->space(AS_PROGRAM).install_read_handler(0x4000, 0x5fff, read16_delegate(FUNC(polepos_state::polepos2_ic25_r),this));
}
/*********************************************************************
* Game drivers
*********************************************************************/
GAME( 1982, polepos, 0, polepos, poleposa, driver_device, 0, ROT0, "Namco", "Pole Position (World)", 0 )
GAME( 1982, poleposj, polepos, polepos, polepos, driver_device, 0, ROT0, "Namco", "Pole Position (Japan)", 0 )
GAME( 1982, poleposa1, polepos, polepos, poleposa, driver_device, 0, ROT0, "Namco (Atari license)", "Pole Position (Atari version 1)", 0 )
GAME( 1982, poleposa2, polepos, polepos, poleposa, driver_device, 0, ROT0, "Namco (Atari license)", "Pole Position (Atari version 2)", 0 )
GAME( 1984, topracer, polepos, polepos, polepos, driver_device, 0, ROT0, "bootleg", "Top Racer (with MB8841 + MB8842, 1984)", 0 ) // the NAMCO customs have been cloned on these bootlegs
GAME( 1983, topracera, polepos, polepos, polepos, driver_device, 0, ROT0, "bootleg", "Top Racer (with MB8841 + MB8842, 1983)", 0 ) // the only difference between them is the year displayed on the title screen
GAME( 1983, ppspeed, polepos, polepos, polepos, driver_device, 0, ROT0, "bootleg", "Speed Up (Spanish bootleg of Pole Position)", 0 ) // very close to topracer / topracera
GAME( 1982, topracern, polepos, topracern, topracern, polepos_state, topracern, ROT0, "bootleg", "Top Racer (no MB8841 + MB8842)", 0 )
GAME( 1983, polepos2, 0, polepos, polepos2j, polepos_state, polepos2, ROT0, "Namco", "Pole Position II (Japan)", 0 )
GAME( 1983, polepos2a, polepos2, polepos, polepos2, polepos_state, polepos2, ROT0, "Namco (Atari license)", "Pole Position II (Atari)", 0 )
GAME( 1983, polepos2b, polepos2, polepos, polepos2, driver_device, 0, ROT0, "bootleg", "Pole Position II (bootleg)", 0 )
GAME( 1984, polepos2bi, polepos2, polepos2bi, topracern, polepos_state, topracern, ROT0, "bootleg", "Gran Premio F1 (Italian bootleg of Pole Position II)", MACHINE_IMPERFECT_COLORS | MACHINE_IMPERFECT_SOUND ) // should have italian voices
|
RJRetro/mame
|
src/mame/drivers/polepos.cpp
|
C++
|
gpl-2.0
| 120,002 |
cmd_arch/mips/math-emu/dp_add.o := /opt/buildroot-gcc342/bin/mipsel-linux-uclibc-gcc -Wp,-MD,arch/mips/math-emu/.dp_add.o.d -nostdinc -isystem /root/asuswrt-bender/tools/brcm/K26/hndtools-mipsel-uclibc-4.2.4/bin/../lib/gcc/mipsel-linux-uclibc/4.2.4/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O2 -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32r2 -Wa,-mips32r2 -Wa,--trap -Iinclude/asm-mips/rt2880 -Iinclude/asm-mips/mach-generic -fomit-frame-pointer -gdwarf-2 -fno-stack-protector -membedded-data -muninit-const-in-rodata -funit-at-a-time -Wdeclaration-after-statement -Wno-pointer-sign -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(dp_add)" -D"KBUILD_MODNAME=KBUILD_STR(dp_add)" -c -o arch/mips/math-emu/dp_add.o arch/mips/math-emu/dp_add.c
deps_arch/mips/math-emu/dp_add.o := \
arch/mips/math-emu/dp_add.c \
arch/mips/math-emu/ieee754dp.h \
arch/mips/math-emu/ieee754int.h \
arch/mips/math-emu/ieee754.h \
include/asm/byteorder.h \
$(wildcard include/config/cpu/mipsr2.h) \
$(wildcard include/config/cpu/mips64/r2.h) \
include/linux/compiler.h \
$(wildcard include/config/enable/must/check.h) \
include/linux/compiler-gcc4.h \
$(wildcard include/config/forced/inlining.h) \
include/linux/compiler-gcc.h \
include/asm/types.h \
$(wildcard include/config/highmem.h) \
$(wildcard include/config/64bit/phys/addr.h) \
$(wildcard include/config/64bit.h) \
include/linux/byteorder/little_endian.h \
include/linux/types.h \
$(wildcard include/config/uid16.h) \
$(wildcard include/config/lbd.h) \
$(wildcard include/config/lsf.h) \
$(wildcard include/config/resources/64bit.h) \
include/linux/posix_types.h \
include/linux/stddef.h \
include/asm/posix_types.h \
include/asm/sgidefs.h \
include/linux/byteorder/swab.h \
include/linux/byteorder/generic.h \
include/linux/sched.h \
$(wildcard include/config/smp.h) \
$(wildcard include/config/no/hz.h) \
$(wildcard include/config/detect/softlockup.h) \
$(wildcard include/config/split/ptlock/cpus.h) \
$(wildcard include/config/keys.h) \
$(wildcard include/config/bsd/process/acct.h) \
$(wildcard include/config/taskstats.h) \
$(wildcard include/config/inotify/user.h) \
$(wildcard include/config/schedstats.h) \
$(wildcard include/config/task/delay/acct.h) \
$(wildcard include/config/blk/dev/io/trace.h) \
$(wildcard include/config/cc/stackprotector.h) \
$(wildcard include/config/sysvipc.h) \
$(wildcard include/config/rt/mutexes.h) \
$(wildcard include/config/debug/mutexes.h) \
$(wildcard include/config/trace/irqflags.h) \
$(wildcard include/config/lockdep.h) \
$(wildcard include/config/task/xacct.h) \
$(wildcard include/config/numa.h) \
$(wildcard include/config/cpusets.h) \
$(wildcard include/config/compat.h) \
$(wildcard include/config/fault/injection.h) \
$(wildcard include/config/hotplug/cpu.h) \
$(wildcard include/config/preempt.h) \
include/linux/auxvec.h \
include/asm/auxvec.h \
include/asm/param.h \
$(wildcard include/config/hz.h) \
include/linux/capability.h \
include/linux/spinlock.h \
$(wildcard include/config/debug/spinlock.h) \
$(wildcard include/config/debug/lock/alloc.h) \
include/linux/preempt.h \
$(wildcard include/config/debug/preempt.h) \
include/linux/thread_info.h \
include/linux/bitops.h \
include/asm/bitops.h \
$(wildcard include/config/cpu/mips32.h) \
$(wildcard include/config/cpu/mips64.h) \
include/linux/irqflags.h \
$(wildcard include/config/trace/irqflags/support.h) \
$(wildcard include/config/x86.h) \
include/asm/irqflags.h \
$(wildcard include/config/mips/mt/smtc.h) \
$(wildcard include/config/irq/cpu.h) \
$(wildcard include/config/mips/mt/smtc/instant/replay.h) \
include/asm/hazards.h \
$(wildcard include/config/cpu/r10000.h) \
$(wildcard include/config/cpu/rm9000.h) \
$(wildcard include/config/cpu/sb1.h) \
include/asm/barrier.h \
$(wildcard include/config/cpu/has/sync.h) \
$(wildcard include/config/cpu/has/wb.h) \
$(wildcard include/config/weak/ordering.h) \
include/asm/bug.h \
$(wildcard include/config/bug.h) \
include/asm/break.h \
include/asm-generic/bug.h \
$(wildcard include/config/generic/bug.h) \
$(wildcard include/config/debug/bugverbose.h) \
include/asm/cpu-features.h \
$(wildcard include/config/32bit.h) \
$(wildcard include/config/cpu/mipsr2/irq/vi.h) \
$(wildcard include/config/cpu/mipsr2/irq/ei.h) \
include/asm/cpu.h \
include/asm/cpu-info.h \
$(wildcard include/config/sgi/ip27.h) \
$(wildcard include/config/mips/mt.h) \
include/asm/cache.h \
$(wildcard include/config/mips/l1/cache/shift.h) \
include/asm-mips/mach-generic/kmalloc.h \
$(wildcard include/config/dma/coherent.h) \
include/asm-mips/mach-generic/cpu-feature-overrides.h \
include/asm/war.h \
$(wildcard include/config/sgi/ip22.h) \
$(wildcard include/config/sni/rm.h) \
$(wildcard include/config/cpu/r5432.h) \
$(wildcard include/config/sb1/pass/1/workarounds.h) \
$(wildcard include/config/sb1/pass/2/workarounds.h) \
$(wildcard include/config/mips/malta.h) \
$(wildcard include/config/mips/atlas.h) \
$(wildcard include/config/mips/sead.h) \
$(wildcard include/config/cpu/tx49xx.h) \
$(wildcard include/config/momenco/jaguar/atx.h) \
$(wildcard include/config/pmc/yosemite.h) \
$(wildcard include/config/basler/excite.h) \
$(wildcard include/config/momenco/ocelot/3.h) \
include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/ffz.h \
include/asm-generic/bitops/find.h \
include/asm-generic/bitops/sched.h \
include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/ext2-non-atomic.h \
include/asm-generic/bitops/le.h \
include/asm-generic/bitops/ext2-atomic.h \
include/asm-generic/bitops/minix.h \
include/asm/thread_info.h \
$(wildcard include/config/page/size/4kb.h) \
$(wildcard include/config/page/size/8kb.h) \
$(wildcard include/config/page/size/16kb.h) \
$(wildcard include/config/page/size/64kb.h) \
$(wildcard include/config/debug/stack/usage.h) \
include/asm/processor.h \
$(wildcard include/config/mips/mt/fpaff.h) \
$(wildcard include/config/cpu/has/prefetch.h) \
include/linux/cpumask.h \
include/linux/kernel.h \
$(wildcard include/config/preempt/voluntary.h) \
$(wildcard include/config/debug/spinlock/sleep.h) \
$(wildcard include/config/printk.h) \
/root/asuswrt-bender/tools/brcm/K26/hndtools-mipsel-uclibc-4.2.4/bin/../lib/gcc/mipsel-linux-uclibc/4.2.4/include/stdarg.h \
include/linux/linkage.h \
include/asm/linkage.h \
include/linux/log2.h \
$(wildcard include/config/arch/has/ilog2/u32.h) \
$(wildcard include/config/arch/has/ilog2/u64.h) \
include/linux/threads.h \
$(wildcard include/config/nr/cpus.h) \
$(wildcard include/config/base/small.h) \
include/linux/bitmap.h \
include/linux/string.h \
include/asm/string.h \
$(wildcard include/config/cpu/r3000.h) \
include/asm/cachectl.h \
include/asm/mipsregs.h \
$(wildcard include/config/cpu/vr41xx.h) \
include/asm/prefetch.h \
include/asm/system.h \
include/asm/addrspace.h \
$(wildcard include/config/cpu/r4300.h) \
$(wildcard include/config/cpu/r4x00.h) \
$(wildcard include/config/cpu/r5000.h) \
$(wildcard include/config/cpu/rm7000.h) \
$(wildcard include/config/cpu/nevada.h) \
$(wildcard include/config/cpu/r8000.h) \
$(wildcard include/config/cpu/sb1a.h) \
include/asm-mips/mach-generic/spaces.h \
$(wildcard include/config/dma/noncoherent.h) \
include/asm/dsp.h \
include/linux/stringify.h \
include/linux/bottom_half.h \
include/linux/spinlock_types.h \
include/linux/lockdep.h \
$(wildcard include/config/generic/hardirqs.h) \
$(wildcard include/config/prove/locking.h) \
include/linux/spinlock_types_up.h \
include/linux/spinlock_up.h \
include/linux/spinlock_api_up.h \
include/asm/atomic.h \
include/asm-generic/atomic.h \
include/asm/current.h \
include/linux/timex.h \
$(wildcard include/config/time/interpolation.h) \
include/linux/time.h \
include/linux/seqlock.h \
include/asm/timex.h \
include/asm-mips/mach-generic/timex.h \
include/linux/jiffies.h \
include/linux/calc64.h \
include/asm/div64.h \
include/asm-generic/div64.h \
include/linux/rbtree.h \
include/linux/errno.h \
include/asm/errno.h \
include/asm-generic/errno-base.h \
include/linux/nodemask.h \
include/linux/numa.h \
$(wildcard include/config/nodes/shift.h) \
include/asm/semaphore.h \
include/linux/wait.h \
include/linux/list.h \
$(wildcard include/config/debug/list.h) \
include/linux/poison.h \
include/linux/prefetch.h \
include/linux/rwsem.h \
$(wildcard include/config/rwsem/generic/spinlock.h) \
include/linux/rwsem-spinlock.h \
include/asm/page.h \
$(wildcard include/config/build/elf64.h) \
$(wildcard include/config/flatmem.h) \
$(wildcard include/config/sparsemem.h) \
$(wildcard include/config/need/multiple/nodes.h) \
$(wildcard include/config/limited/dma.h) \
include/linux/pfn.h \
include/asm/io.h \
include/asm-generic/iomap.h \
include/asm/pgtable-bits.h \
$(wildcard include/config/cpu/mips32/r1.h) \
$(wildcard include/config/cpu/tx39xx.h) \
$(wildcard include/config/mips/uncached.h) \
include/asm-mips/mach-generic/ioremap.h \
include/asm-mips/mach-generic/mangle-port.h \
$(wildcard include/config/swap/io/space.h) \
include/asm-generic/memory_model.h \
$(wildcard include/config/discontigmem.h) \
$(wildcard include/config/out/of/line/pfn/to/page.h) \
include/asm-generic/page.h \
include/asm/ptrace.h \
$(wildcard include/config/cpu/has/smartmips.h) \
include/asm/isadep.h \
include/asm/mmu.h \
include/asm/cputime.h \
include/asm-generic/cputime.h \
include/linux/smp.h \
include/linux/sem.h \
include/linux/ipc.h \
$(wildcard include/config/ipc/ns.h) \
include/asm/ipcbuf.h \
include/linux/kref.h \
include/asm/sembuf.h \
include/linux/signal.h \
include/asm/signal.h \
$(wildcard include/config/trad/signals.h) \
$(wildcard include/config/binfmt/irix.h) \
include/asm-generic/signal.h \
include/asm/sigcontext.h \
include/asm/siginfo.h \
include/asm-generic/siginfo.h \
include/linux/securebits.h \
include/linux/fs_struct.h \
include/linux/completion.h \
include/linux/pid.h \
include/linux/rcupdate.h \
include/linux/cache.h \
$(wildcard include/config/arch/has/cache/line/size.h) \
include/linux/percpu.h \
include/linux/slab.h \
$(wildcard include/config/slab/debug.h) \
$(wildcard include/config/slub.h) \
$(wildcard include/config/slob.h) \
$(wildcard include/config/debug/slab.h) \
include/linux/gfp.h \
$(wildcard include/config/zone/dma.h) \
$(wildcard include/config/zone/dma32.h) \
include/linux/mmzone.h \
$(wildcard include/config/force/max/zoneorder.h) \
$(wildcard include/config/memory/hotplug.h) \
$(wildcard include/config/arch/populates/node/map.h) \
$(wildcard include/config/flat/node/mem/map.h) \
$(wildcard include/config/have/memory/present.h) \
$(wildcard include/config/need/node/memmap/size.h) \
$(wildcard include/config/have/arch/early/pfn/to/nid.h) \
$(wildcard include/config/sparsemem/extreme.h) \
$(wildcard include/config/nodes/span/other/nodes.h) \
$(wildcard include/config/holes/in/zone.h) \
include/linux/init.h \
$(wildcard include/config/modules.h) \
$(wildcard include/config/hotplug.h) \
$(wildcard include/config/acpi/hotplug/memory.h) \
include/linux/memory_hotplug.h \
$(wildcard include/config/have/arch/nodedata/extension.h) \
include/linux/notifier.h \
include/linux/mutex.h \
include/linux/srcu.h \
include/linux/topology.h \
$(wildcard include/config/sched/smt.h) \
$(wildcard include/config/sched/mc.h) \
include/asm/topology.h \
include/asm-mips/mach-generic/topology.h \
include/asm-generic/topology.h \
include/linux/slub_def.h \
include/linux/workqueue.h \
include/linux/timer.h \
$(wildcard include/config/timer/stats.h) \
include/linux/ktime.h \
$(wildcard include/config/ktime/scalar.h) \
include/linux/kobject.h \
include/linux/sysfs.h \
$(wildcard include/config/sysfs.h) \
include/asm/percpu.h \
include/asm-generic/percpu.h \
include/linux/seccomp.h \
$(wildcard include/config/seccomp.h) \
include/linux/futex.h \
$(wildcard include/config/futex.h) \
include/linux/rtmutex.h \
$(wildcard include/config/debug/rt/mutexes.h) \
include/linux/plist.h \
$(wildcard include/config/debug/pi/list.h) \
include/linux/param.h \
include/linux/resource.h \
include/asm/resource.h \
include/asm-generic/resource.h \
include/linux/hrtimer.h \
$(wildcard include/config/high/res/timers.h) \
include/linux/task_io_accounting.h \
$(wildcard include/config/task/io/accounting.h) \
include/linux/aio.h \
include/linux/aio_abi.h \
include/linux/uio.h \
arch/mips/math-emu/dp_add.o: $(deps_arch/mips/math-emu/dp_add.o)
$(deps_arch/mips/math-emu/dp_add.o):
|
matteocrippa/dsl-n55u-bender
|
release/src-ra/linux/linux-2.6.21.x/arch/mips/math-emu/.dp_add.o.cmd
|
Batchfile
|
gpl-2.0
| 13,444 |
/* Copyright (C) 2005 MySQL AB
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.
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 beginnings of locale(7) support.
Sponsored for subset of LC_TIME support, WorkLog entry 2928, -- Josh Chamas
!! This file is built from my_locale.pl !!
*/
#include "mysql_priv.h"
/***** LOCALE BEGIN ar_AE: Arabic - United Arab Emirates *****/
static const char *my_locale_month_names_ar_AE[13] =
{"يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر", NullS };
static const char *my_locale_ab_month_names_ar_AE[13] =
{"ينا","فبر","مار","أبر","ماي","يون","يول","أغس","سبت","أكت","نوف","ديس", NullS };
static const char *my_locale_day_names_ar_AE[8] =
{"الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت ","الأحد", NullS };
static const char *my_locale_ab_day_names_ar_AE[8] =
{"ن","ث","ر","خ","ج","س","ح", NullS };
static TYPELIB my_locale_typelib_month_names_ar_AE =
{ array_elements(my_locale_month_names_ar_AE)-1, "", my_locale_month_names_ar_AE, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ar_AE =
{ array_elements(my_locale_ab_month_names_ar_AE)-1, "", my_locale_ab_month_names_ar_AE, NULL };
static TYPELIB my_locale_typelib_day_names_ar_AE =
{ array_elements(my_locale_day_names_ar_AE)-1, "", my_locale_day_names_ar_AE, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ar_AE =
{ array_elements(my_locale_ab_day_names_ar_AE)-1, "", my_locale_ab_day_names_ar_AE, NULL };
MY_LOCALE my_locale_ar_AE
(
6,
"ar_AE",
"Arabic - United Arab Emirates",
FALSE,
&my_locale_typelib_month_names_ar_AE,
&my_locale_typelib_ab_month_names_ar_AE,
&my_locale_typelib_day_names_ar_AE,
&my_locale_typelib_ab_day_names_ar_AE,
6,
8
);
/***** LOCALE END ar_AE *****/
/***** LOCALE BEGIN ar_BH: Arabic - Bahrain *****/
static const char *my_locale_month_names_ar_BH[13] =
{"يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر", NullS };
static const char *my_locale_ab_month_names_ar_BH[13] =
{"ينا","فبر","مار","أبر","ماي","يون","يول","أغس","سبت","أكت","نوف","ديس", NullS };
static const char *my_locale_day_names_ar_BH[8] =
{"الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت","الأحد", NullS };
static const char *my_locale_ab_day_names_ar_BH[8] =
{"ن","ث","ر","خ","ج","س","ح", NullS };
static TYPELIB my_locale_typelib_month_names_ar_BH =
{ array_elements(my_locale_month_names_ar_BH)-1, "", my_locale_month_names_ar_BH, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ar_BH =
{ array_elements(my_locale_ab_month_names_ar_BH)-1, "", my_locale_ab_month_names_ar_BH, NULL };
static TYPELIB my_locale_typelib_day_names_ar_BH =
{ array_elements(my_locale_day_names_ar_BH)-1, "", my_locale_day_names_ar_BH, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ar_BH =
{ array_elements(my_locale_ab_day_names_ar_BH)-1, "", my_locale_ab_day_names_ar_BH, NULL };
MY_LOCALE my_locale_ar_BH
(
7,
"ar_BH",
"Arabic - Bahrain",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_BH *****/
/***** LOCALE BEGIN ar_JO: Arabic - Jordan *****/
static const char *my_locale_month_names_ar_JO[13] =
{"كانون الثاني","شباط","آذار","نيسان","نوار","حزيران","تموز","آب","أيلول","تشرين الأول","تشرين الثاني","كانون الأول", NullS };
static const char *my_locale_ab_month_names_ar_JO[13] =
{"كانون الثاني","شباط","آذار","نيسان","نوار","حزيران","تموز","آب","أيلول","تشرين الأول","تشرين الثاني","كانون الأول", NullS };
static const char *my_locale_day_names_ar_JO[8] =
{"الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت","الأحد", NullS };
static const char *my_locale_ab_day_names_ar_JO[8] =
{"الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت","الأحد", NullS };
static TYPELIB my_locale_typelib_month_names_ar_JO =
{ array_elements(my_locale_month_names_ar_JO)-1, "", my_locale_month_names_ar_JO, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ar_JO =
{ array_elements(my_locale_ab_month_names_ar_JO)-1, "", my_locale_ab_month_names_ar_JO, NULL };
static TYPELIB my_locale_typelib_day_names_ar_JO =
{ array_elements(my_locale_day_names_ar_JO)-1, "", my_locale_day_names_ar_JO, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ar_JO =
{ array_elements(my_locale_ab_day_names_ar_JO)-1, "", my_locale_ab_day_names_ar_JO, NULL };
MY_LOCALE my_locale_ar_JO
(
8,
"ar_JO",
"Arabic - Jordan",
FALSE,
&my_locale_typelib_month_names_ar_JO,
&my_locale_typelib_ab_month_names_ar_JO,
&my_locale_typelib_day_names_ar_JO,
&my_locale_typelib_ab_day_names_ar_JO,
12,
8
);
/***** LOCALE END ar_JO *****/
/***** LOCALE BEGIN ar_SA: Arabic - Saudi Arabia *****/
static const char *my_locale_month_names_ar_SA[13] =
{"كانون الثاني","شباط","آذار","نيسـان","أيار","حزيران","تـمـوز","آب","أيلول","تشرين الأول","تشرين الثاني","كانون الأول", NullS };
static const char *my_locale_ab_month_names_ar_SA[13] =
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec", NullS };
static const char *my_locale_day_names_ar_SA[8] =
{"الإثنين","الثلاثاء","الأربعاء","الخميس","الجمعـة","السبت","الأحد", NullS };
static const char *my_locale_ab_day_names_ar_SA[8] =
{"Mon","Tue","Wed","Thu","Fri","Sat","Sun", NullS };
static TYPELIB my_locale_typelib_month_names_ar_SA =
{ array_elements(my_locale_month_names_ar_SA)-1, "", my_locale_month_names_ar_SA, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ar_SA =
{ array_elements(my_locale_ab_month_names_ar_SA)-1, "", my_locale_ab_month_names_ar_SA, NULL };
static TYPELIB my_locale_typelib_day_names_ar_SA =
{ array_elements(my_locale_day_names_ar_SA)-1, "", my_locale_day_names_ar_SA, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ar_SA =
{ array_elements(my_locale_ab_day_names_ar_SA)-1, "", my_locale_ab_day_names_ar_SA, NULL };
MY_LOCALE my_locale_ar_SA
(
9,
"ar_SA",
"Arabic - Saudi Arabia",
FALSE,
&my_locale_typelib_month_names_ar_SA,
&my_locale_typelib_ab_month_names_ar_SA,
&my_locale_typelib_day_names_ar_SA,
&my_locale_typelib_ab_day_names_ar_SA,
12,
8
);
/***** LOCALE END ar_SA *****/
/***** LOCALE BEGIN ar_SY: Arabic - Syria *****/
static const char *my_locale_month_names_ar_SY[13] =
{"كانون الثاني","شباط","آذار","نيسان","نواران","حزير","تموز","آب","أيلول","تشرين الأول","تشرين الثاني","كانون الأول", NullS };
static const char *my_locale_ab_month_names_ar_SY[13] =
{"كانون الثاني","شباط","آذار","نيسان","نوار","حزيران","تموز","آب","أيلول","تشرين الأول","تشرين الثاني","كانون الأول", NullS };
static const char *my_locale_day_names_ar_SY[8] =
{"الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت","الأحد", NullS };
static const char *my_locale_ab_day_names_ar_SY[8] =
{"الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت","الأحد", NullS };
static TYPELIB my_locale_typelib_month_names_ar_SY =
{ array_elements(my_locale_month_names_ar_SY)-1, "", my_locale_month_names_ar_SY, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ar_SY =
{ array_elements(my_locale_ab_month_names_ar_SY)-1, "", my_locale_ab_month_names_ar_SY, NULL };
static TYPELIB my_locale_typelib_day_names_ar_SY =
{ array_elements(my_locale_day_names_ar_SY)-1, "", my_locale_day_names_ar_SY, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ar_SY =
{ array_elements(my_locale_ab_day_names_ar_SY)-1, "", my_locale_ab_day_names_ar_SY, NULL };
MY_LOCALE my_locale_ar_SY
(
10,
"ar_SY",
"Arabic - Syria",
FALSE,
&my_locale_typelib_month_names_ar_SY,
&my_locale_typelib_ab_month_names_ar_SY,
&my_locale_typelib_day_names_ar_SY,
&my_locale_typelib_ab_day_names_ar_SY,
12,
8
);
/***** LOCALE END ar_SY *****/
/***** LOCALE BEGIN be_BY: Belarusian - Belarus *****/
static const char *my_locale_month_names_be_BY[13] =
{"Студзень","Люты","Сакавік","Красавік","Травень","Чэрвень","Ліпень","Жнівень","Верасень","Кастрычнік","Лістапад","Снежань", NullS };
static const char *my_locale_ab_month_names_be_BY[13] =
{"Стд","Лют","Сак","Крс","Тра","Чэр","Ліп","Жнв","Врс","Кст","Ліс","Снж", NullS };
static const char *my_locale_day_names_be_BY[8] =
{"Панядзелак","Аўторак","Серада","Чацвер","Пятніца","Субота","Нядзеля", NullS };
static const char *my_locale_ab_day_names_be_BY[8] =
{"Пан","Аўт","Срд","Чцв","Пят","Суб","Няд", NullS };
static TYPELIB my_locale_typelib_month_names_be_BY =
{ array_elements(my_locale_month_names_be_BY)-1, "", my_locale_month_names_be_BY, NULL };
static TYPELIB my_locale_typelib_ab_month_names_be_BY =
{ array_elements(my_locale_ab_month_names_be_BY)-1, "", my_locale_ab_month_names_be_BY, NULL };
static TYPELIB my_locale_typelib_day_names_be_BY =
{ array_elements(my_locale_day_names_be_BY)-1, "", my_locale_day_names_be_BY, NULL };
static TYPELIB my_locale_typelib_ab_day_names_be_BY =
{ array_elements(my_locale_ab_day_names_be_BY)-1, "", my_locale_ab_day_names_be_BY, NULL };
MY_LOCALE my_locale_be_BY
(
11,
"be_BY",
"Belarusian - Belarus",
FALSE,
&my_locale_typelib_month_names_be_BY,
&my_locale_typelib_ab_month_names_be_BY,
&my_locale_typelib_day_names_be_BY,
&my_locale_typelib_ab_day_names_be_BY,
10,
10
);
/***** LOCALE END be_BY *****/
/***** LOCALE BEGIN bg_BG: Bulgarian - Bulgaria *****/
static const char *my_locale_month_names_bg_BG[13] =
{"януари","февруари","март","април","май","юни","юли","август","септември","октомври","ноември","декември", NullS };
static const char *my_locale_ab_month_names_bg_BG[13] =
{"яну","фев","мар","апр","май","юни","юли","авг","сеп","окт","ное","дек", NullS };
static const char *my_locale_day_names_bg_BG[8] =
{"понеделник","вторник","сряда","четвъртък","петък","събота","неделя", NullS };
static const char *my_locale_ab_day_names_bg_BG[8] =
{"пн","вт","ср","чт","пт","сб","нд", NullS };
static TYPELIB my_locale_typelib_month_names_bg_BG =
{ array_elements(my_locale_month_names_bg_BG)-1, "", my_locale_month_names_bg_BG, NULL };
static TYPELIB my_locale_typelib_ab_month_names_bg_BG =
{ array_elements(my_locale_ab_month_names_bg_BG)-1, "", my_locale_ab_month_names_bg_BG, NULL };
static TYPELIB my_locale_typelib_day_names_bg_BG =
{ array_elements(my_locale_day_names_bg_BG)-1, "", my_locale_day_names_bg_BG, NULL };
static TYPELIB my_locale_typelib_ab_day_names_bg_BG =
{ array_elements(my_locale_ab_day_names_bg_BG)-1, "", my_locale_ab_day_names_bg_BG, NULL };
MY_LOCALE my_locale_bg_BG
(
12,
"bg_BG",
"Bulgarian - Bulgaria",
FALSE,
&my_locale_typelib_month_names_bg_BG,
&my_locale_typelib_ab_month_names_bg_BG,
&my_locale_typelib_day_names_bg_BG,
&my_locale_typelib_ab_day_names_bg_BG,
9,
10
);
/***** LOCALE END bg_BG *****/
/***** LOCALE BEGIN ca_ES: Catalan - Catalan *****/
static const char *my_locale_month_names_ca_ES[13] =
{"gener","febrer","març","abril","maig","juny","juliol","agost","setembre","octubre","novembre","desembre", NullS };
static const char *my_locale_ab_month_names_ca_ES[13] =
{"gen","feb","mar","abr","mai","jun","jul","ago","set","oct","nov","des", NullS };
static const char *my_locale_day_names_ca_ES[8] =
{"dilluns","dimarts","dimecres","dijous","divendres","dissabte","diumenge", NullS };
static const char *my_locale_ab_day_names_ca_ES[8] =
{"dl","dt","dc","dj","dv","ds","dg", NullS };
static TYPELIB my_locale_typelib_month_names_ca_ES =
{ array_elements(my_locale_month_names_ca_ES)-1, "", my_locale_month_names_ca_ES, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ca_ES =
{ array_elements(my_locale_ab_month_names_ca_ES)-1, "", my_locale_ab_month_names_ca_ES, NULL };
static TYPELIB my_locale_typelib_day_names_ca_ES =
{ array_elements(my_locale_day_names_ca_ES)-1, "", my_locale_day_names_ca_ES, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ca_ES =
{ array_elements(my_locale_ab_day_names_ca_ES)-1, "", my_locale_ab_day_names_ca_ES, NULL };
MY_LOCALE my_locale_ca_ES
(
13,
"ca_ES",
"Catalan - Catalan",
FALSE,
&my_locale_typelib_month_names_ca_ES,
&my_locale_typelib_ab_month_names_ca_ES,
&my_locale_typelib_day_names_ca_ES,
&my_locale_typelib_ab_day_names_ca_ES,
8,
9
);
/***** LOCALE END ca_ES *****/
/***** LOCALE BEGIN cs_CZ: Czech - Czech Republic *****/
static const char *my_locale_month_names_cs_CZ[13] =
{"leden","únor","březen","duben","květen","červen","červenec","srpen","září","říjen","listopad","prosinec", NullS };
static const char *my_locale_ab_month_names_cs_CZ[13] =
{"led","úno","bře","dub","kvě","čen","čec","srp","zář","říj","lis","pro", NullS };
static const char *my_locale_day_names_cs_CZ[8] =
{"Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota","Neděle", NullS };
static const char *my_locale_ab_day_names_cs_CZ[8] =
{"Po","Út","St","Čt","Pá","So","Ne", NullS };
static TYPELIB my_locale_typelib_month_names_cs_CZ =
{ array_elements(my_locale_month_names_cs_CZ)-1, "", my_locale_month_names_cs_CZ, NULL };
static TYPELIB my_locale_typelib_ab_month_names_cs_CZ =
{ array_elements(my_locale_ab_month_names_cs_CZ)-1, "", my_locale_ab_month_names_cs_CZ, NULL };
static TYPELIB my_locale_typelib_day_names_cs_CZ =
{ array_elements(my_locale_day_names_cs_CZ)-1, "", my_locale_day_names_cs_CZ, NULL };
static TYPELIB my_locale_typelib_ab_day_names_cs_CZ =
{ array_elements(my_locale_ab_day_names_cs_CZ)-1, "", my_locale_ab_day_names_cs_CZ, NULL };
MY_LOCALE my_locale_cs_CZ
(
14,
"cs_CZ",
"Czech - Czech Republic",
FALSE,
&my_locale_typelib_month_names_cs_CZ,
&my_locale_typelib_ab_month_names_cs_CZ,
&my_locale_typelib_day_names_cs_CZ,
&my_locale_typelib_ab_day_names_cs_CZ,
8,
7
);
/***** LOCALE END cs_CZ *****/
/***** LOCALE BEGIN da_DK: Danish - Denmark *****/
static const char *my_locale_month_names_da_DK[13] =
{"januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december", NullS };
static const char *my_locale_ab_month_names_da_DK[13] =
{"jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec", NullS };
static const char *my_locale_day_names_da_DK[8] =
{"mandag","tirsdag","onsdag","torsdag","fredag","lørdag","søndag", NullS };
static const char *my_locale_ab_day_names_da_DK[8] =
{"man","tir","ons","tor","fre","lør","søn", NullS };
static TYPELIB my_locale_typelib_month_names_da_DK =
{ array_elements(my_locale_month_names_da_DK)-1, "", my_locale_month_names_da_DK, NULL };
static TYPELIB my_locale_typelib_ab_month_names_da_DK =
{ array_elements(my_locale_ab_month_names_da_DK)-1, "", my_locale_ab_month_names_da_DK, NULL };
static TYPELIB my_locale_typelib_day_names_da_DK =
{ array_elements(my_locale_day_names_da_DK)-1, "", my_locale_day_names_da_DK, NULL };
static TYPELIB my_locale_typelib_ab_day_names_da_DK =
{ array_elements(my_locale_ab_day_names_da_DK)-1, "", my_locale_ab_day_names_da_DK, NULL };
MY_LOCALE my_locale_da_DK
(
15,
"da_DK",
"Danish - Denmark",
FALSE,
&my_locale_typelib_month_names_da_DK,
&my_locale_typelib_ab_month_names_da_DK,
&my_locale_typelib_day_names_da_DK,
&my_locale_typelib_ab_day_names_da_DK,
9,
7
);
/***** LOCALE END da_DK *****/
/***** LOCALE BEGIN de_AT: German - Austria *****/
static const char *my_locale_month_names_de_AT[13] =
{"Jänner","Feber","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember", NullS };
static const char *my_locale_ab_month_names_de_AT[13] =
{"Jän","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez", NullS };
static const char *my_locale_day_names_de_AT[8] =
{"Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","Sonntag", NullS };
static const char *my_locale_ab_day_names_de_AT[8] =
{"Mon","Die","Mit","Don","Fre","Sam","Son", NullS };
static TYPELIB my_locale_typelib_month_names_de_AT =
{ array_elements(my_locale_month_names_de_AT)-1, "", my_locale_month_names_de_AT, NULL };
static TYPELIB my_locale_typelib_ab_month_names_de_AT =
{ array_elements(my_locale_ab_month_names_de_AT)-1, "", my_locale_ab_month_names_de_AT, NULL };
static TYPELIB my_locale_typelib_day_names_de_AT =
{ array_elements(my_locale_day_names_de_AT)-1, "", my_locale_day_names_de_AT, NULL };
static TYPELIB my_locale_typelib_ab_day_names_de_AT =
{ array_elements(my_locale_ab_day_names_de_AT)-1, "", my_locale_ab_day_names_de_AT, NULL };
MY_LOCALE my_locale_de_AT
(
16,
"de_AT",
"German - Austria",
FALSE,
&my_locale_typelib_month_names_de_AT,
&my_locale_typelib_ab_month_names_de_AT,
&my_locale_typelib_day_names_de_AT,
&my_locale_typelib_ab_day_names_de_AT,
9,
10
);
/***** LOCALE END de_AT *****/
/***** LOCALE BEGIN de_DE: German - Germany *****/
static const char *my_locale_month_names_de_DE[13] =
{"Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember", NullS };
static const char *my_locale_ab_month_names_de_DE[13] =
{"Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez", NullS };
static const char *my_locale_day_names_de_DE[8] =
{"Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","Sonntag", NullS };
static const char *my_locale_ab_day_names_de_DE[8] =
{"Mo","Di","Mi","Do","Fr","Sa","So", NullS };
static TYPELIB my_locale_typelib_month_names_de_DE =
{ array_elements(my_locale_month_names_de_DE)-1, "", my_locale_month_names_de_DE, NULL };
static TYPELIB my_locale_typelib_ab_month_names_de_DE =
{ array_elements(my_locale_ab_month_names_de_DE)-1, "", my_locale_ab_month_names_de_DE, NULL };
static TYPELIB my_locale_typelib_day_names_de_DE =
{ array_elements(my_locale_day_names_de_DE)-1, "", my_locale_day_names_de_DE, NULL };
static TYPELIB my_locale_typelib_ab_day_names_de_DE =
{ array_elements(my_locale_ab_day_names_de_DE)-1, "", my_locale_ab_day_names_de_DE, NULL };
MY_LOCALE my_locale_de_DE
(
4,
"de_DE",
"German - Germany",
FALSE,
&my_locale_typelib_month_names_de_DE,
&my_locale_typelib_ab_month_names_de_DE,
&my_locale_typelib_day_names_de_DE,
&my_locale_typelib_ab_day_names_de_DE,
9,
10
);
/***** LOCALE END de_DE *****/
/***** LOCALE BEGIN en_US: English - United States *****/
static const char *my_locale_month_names_en_US[13] =
{"January","February","March","April","May","June","July","August","September","October","November","December", NullS };
static const char *my_locale_ab_month_names_en_US[13] =
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec", NullS };
static const char *my_locale_day_names_en_US[8] =
{"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday", NullS };
static const char *my_locale_ab_day_names_en_US[8] =
{"Mon","Tue","Wed","Thu","Fri","Sat","Sun", NullS };
static TYPELIB my_locale_typelib_month_names_en_US =
{ array_elements(my_locale_month_names_en_US)-1, "", my_locale_month_names_en_US, NULL };
static TYPELIB my_locale_typelib_ab_month_names_en_US =
{ array_elements(my_locale_ab_month_names_en_US)-1, "", my_locale_ab_month_names_en_US, NULL };
static TYPELIB my_locale_typelib_day_names_en_US =
{ array_elements(my_locale_day_names_en_US)-1, "", my_locale_day_names_en_US, NULL };
static TYPELIB my_locale_typelib_ab_day_names_en_US =
{ array_elements(my_locale_ab_day_names_en_US)-1, "", my_locale_ab_day_names_en_US, NULL };
MY_LOCALE my_locale_en_US
(
0,
"en_US",
"English - United States",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_US *****/
/***** LOCALE BEGIN es_ES: Spanish - Spain *****/
static const char *my_locale_month_names_es_ES[13] =
{"enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre", NullS };
static const char *my_locale_ab_month_names_es_ES[13] =
{"ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic", NullS };
static const char *my_locale_day_names_es_ES[8] =
{"lunes","martes","miércoles","jueves","viernes","sábado","domingo", NullS };
static const char *my_locale_ab_day_names_es_ES[8] =
{"lun","mar","mié","jue","vie","sáb","dom", NullS };
static TYPELIB my_locale_typelib_month_names_es_ES =
{ array_elements(my_locale_month_names_es_ES)-1, "", my_locale_month_names_es_ES, NULL };
static TYPELIB my_locale_typelib_ab_month_names_es_ES =
{ array_elements(my_locale_ab_month_names_es_ES)-1, "", my_locale_ab_month_names_es_ES, NULL };
static TYPELIB my_locale_typelib_day_names_es_ES =
{ array_elements(my_locale_day_names_es_ES)-1, "", my_locale_day_names_es_ES, NULL };
static TYPELIB my_locale_typelib_ab_day_names_es_ES =
{ array_elements(my_locale_ab_day_names_es_ES)-1, "", my_locale_ab_day_names_es_ES, NULL };
MY_LOCALE my_locale_es_ES
(
17,
"es_ES",
"Spanish - Spain",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_ES *****/
/***** LOCALE BEGIN et_EE: Estonian - Estonia *****/
static const char *my_locale_month_names_et_EE[13] =
{"jaanuar","veebruar","märts","aprill","mai","juuni","juuli","august","september","oktoober","november","detsember", NullS };
static const char *my_locale_ab_month_names_et_EE[13] =
{"jaan ","veebr","märts","apr ","mai ","juuni","juuli","aug ","sept ","okt ","nov ","dets ", NullS };
static const char *my_locale_day_names_et_EE[8] =
{"esmaspäev","teisipäev","kolmapäev","neljapäev","reede","laupäev","pühapäev", NullS };
static const char *my_locale_ab_day_names_et_EE[8] =
{"E","T","K","N","R","L","P", NullS };
static TYPELIB my_locale_typelib_month_names_et_EE =
{ array_elements(my_locale_month_names_et_EE)-1, "", my_locale_month_names_et_EE, NULL };
static TYPELIB my_locale_typelib_ab_month_names_et_EE =
{ array_elements(my_locale_ab_month_names_et_EE)-1, "", my_locale_ab_month_names_et_EE, NULL };
static TYPELIB my_locale_typelib_day_names_et_EE =
{ array_elements(my_locale_day_names_et_EE)-1, "", my_locale_day_names_et_EE, NULL };
static TYPELIB my_locale_typelib_ab_day_names_et_EE =
{ array_elements(my_locale_ab_day_names_et_EE)-1, "", my_locale_ab_day_names_et_EE, NULL };
MY_LOCALE my_locale_et_EE
(
18,
"et_EE",
"Estonian - Estonia",
FALSE,
&my_locale_typelib_month_names_et_EE,
&my_locale_typelib_ab_month_names_et_EE,
&my_locale_typelib_day_names_et_EE,
&my_locale_typelib_ab_day_names_et_EE,
9,
9
);
/***** LOCALE END et_EE *****/
/***** LOCALE BEGIN eu_ES: Basque - Basque *****/
static const char *my_locale_month_names_eu_ES[13] =
{"urtarrila","otsaila","martxoa","apirila","maiatza","ekaina","uztaila","abuztua","iraila","urria","azaroa","abendua", NullS };
static const char *my_locale_ab_month_names_eu_ES[13] =
{"urt","ots","mar","api","mai","eka","uzt","abu","ira","urr","aza","abe", NullS };
static const char *my_locale_day_names_eu_ES[8] =
{"astelehena","asteartea","asteazkena","osteguna","ostirala","larunbata","igandea", NullS };
static const char *my_locale_ab_day_names_eu_ES[8] =
{"al.","ar.","az.","og.","or.","lr.","ig.", NullS };
static TYPELIB my_locale_typelib_month_names_eu_ES =
{ array_elements(my_locale_month_names_eu_ES)-1, "", my_locale_month_names_eu_ES, NULL };
static TYPELIB my_locale_typelib_ab_month_names_eu_ES =
{ array_elements(my_locale_ab_month_names_eu_ES)-1, "", my_locale_ab_month_names_eu_ES, NULL };
static TYPELIB my_locale_typelib_day_names_eu_ES =
{ array_elements(my_locale_day_names_eu_ES)-1, "", my_locale_day_names_eu_ES, NULL };
static TYPELIB my_locale_typelib_ab_day_names_eu_ES =
{ array_elements(my_locale_ab_day_names_eu_ES)-1, "", my_locale_ab_day_names_eu_ES, NULL };
MY_LOCALE my_locale_eu_ES
(
19,
"eu_ES",
"Basque - Basque",
TRUE,
&my_locale_typelib_month_names_eu_ES,
&my_locale_typelib_ab_month_names_eu_ES,
&my_locale_typelib_day_names_eu_ES,
&my_locale_typelib_ab_day_names_eu_ES,
9,
10
);
/***** LOCALE END eu_ES *****/
/***** LOCALE BEGIN fi_FI: Finnish - Finland *****/
static const char *my_locale_month_names_fi_FI[13] =
{"tammikuu","helmikuu","maaliskuu","huhtikuu","toukokuu","kesäkuu","heinäkuu","elokuu","syyskuu","lokakuu","marraskuu","joulukuu", NullS };
static const char *my_locale_ab_month_names_fi_FI[13] =
{"tammi ","helmi ","maalis","huhti ","touko ","kesä ","heinä ","elo ","syys ","loka ","marras","joulu ", NullS };
static const char *my_locale_day_names_fi_FI[8] =
{"maanantai","tiistai","keskiviikko","torstai","perjantai","lauantai","sunnuntai", NullS };
static const char *my_locale_ab_day_names_fi_FI[8] =
{"ma","ti","ke","to","pe","la","su", NullS };
static TYPELIB my_locale_typelib_month_names_fi_FI =
{ array_elements(my_locale_month_names_fi_FI)-1, "", my_locale_month_names_fi_FI, NULL };
static TYPELIB my_locale_typelib_ab_month_names_fi_FI =
{ array_elements(my_locale_ab_month_names_fi_FI)-1, "", my_locale_ab_month_names_fi_FI, NULL };
static TYPELIB my_locale_typelib_day_names_fi_FI =
{ array_elements(my_locale_day_names_fi_FI)-1, "", my_locale_day_names_fi_FI, NULL };
static TYPELIB my_locale_typelib_ab_day_names_fi_FI =
{ array_elements(my_locale_ab_day_names_fi_FI)-1, "", my_locale_ab_day_names_fi_FI, NULL };
MY_LOCALE my_locale_fi_FI
(
20,
"fi_FI",
"Finnish - Finland",
FALSE,
&my_locale_typelib_month_names_fi_FI,
&my_locale_typelib_ab_month_names_fi_FI,
&my_locale_typelib_day_names_fi_FI,
&my_locale_typelib_ab_day_names_fi_FI,
9,
11
);
/***** LOCALE END fi_FI *****/
/***** LOCALE BEGIN fo_FO: Faroese - Faroe Islands *****/
static const char *my_locale_month_names_fo_FO[13] =
{"januar","februar","mars","apríl","mai","juni","juli","august","september","oktober","november","desember", NullS };
static const char *my_locale_ab_month_names_fo_FO[13] =
{"jan","feb","mar","apr","mai","jun","jul","aug","sep","okt","nov","des", NullS };
static const char *my_locale_day_names_fo_FO[8] =
{"mánadagur","týsdagur","mikudagur","hósdagur","fríggjadagur","leygardagur","sunnudagur", NullS };
static const char *my_locale_ab_day_names_fo_FO[8] =
{"mán","týs","mik","hós","frí","ley","sun", NullS };
static TYPELIB my_locale_typelib_month_names_fo_FO =
{ array_elements(my_locale_month_names_fo_FO)-1, "", my_locale_month_names_fo_FO, NULL };
static TYPELIB my_locale_typelib_ab_month_names_fo_FO =
{ array_elements(my_locale_ab_month_names_fo_FO)-1, "", my_locale_ab_month_names_fo_FO, NULL };
static TYPELIB my_locale_typelib_day_names_fo_FO =
{ array_elements(my_locale_day_names_fo_FO)-1, "", my_locale_day_names_fo_FO, NULL };
static TYPELIB my_locale_typelib_ab_day_names_fo_FO =
{ array_elements(my_locale_ab_day_names_fo_FO)-1, "", my_locale_ab_day_names_fo_FO, NULL };
MY_LOCALE my_locale_fo_FO
(
21,
"fo_FO",
"Faroese - Faroe Islands",
FALSE,
&my_locale_typelib_month_names_fo_FO,
&my_locale_typelib_ab_month_names_fo_FO,
&my_locale_typelib_day_names_fo_FO,
&my_locale_typelib_ab_day_names_fo_FO,
9,
12
);
/***** LOCALE END fo_FO *****/
/***** LOCALE BEGIN fr_FR: French - France *****/
static const char *my_locale_month_names_fr_FR[13] =
{"janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre", NullS };
static const char *my_locale_ab_month_names_fr_FR[13] =
{"jan","fév","mar","avr","mai","jun","jui","aoû","sep","oct","nov","déc", NullS };
static const char *my_locale_day_names_fr_FR[8] =
{"lundi","mardi","mercredi","jeudi","vendredi","samedi","dimanche", NullS };
static const char *my_locale_ab_day_names_fr_FR[8] =
{"lun","mar","mer","jeu","ven","sam","dim", NullS };
static TYPELIB my_locale_typelib_month_names_fr_FR =
{ array_elements(my_locale_month_names_fr_FR)-1, "", my_locale_month_names_fr_FR, NULL };
static TYPELIB my_locale_typelib_ab_month_names_fr_FR =
{ array_elements(my_locale_ab_month_names_fr_FR)-1, "", my_locale_ab_month_names_fr_FR, NULL };
static TYPELIB my_locale_typelib_day_names_fr_FR =
{ array_elements(my_locale_day_names_fr_FR)-1, "", my_locale_day_names_fr_FR, NULL };
static TYPELIB my_locale_typelib_ab_day_names_fr_FR =
{ array_elements(my_locale_ab_day_names_fr_FR)-1, "", my_locale_ab_day_names_fr_FR, NULL };
MY_LOCALE my_locale_fr_FR
(
5,
"fr_FR",
"French - France",
FALSE,
&my_locale_typelib_month_names_fr_FR,
&my_locale_typelib_ab_month_names_fr_FR,
&my_locale_typelib_day_names_fr_FR,
&my_locale_typelib_ab_day_names_fr_FR,
9,
8
);
/***** LOCALE END fr_FR *****/
/***** LOCALE BEGIN gl_ES: Galician - Galician *****/
static const char *my_locale_month_names_gl_ES[13] =
{"Xaneiro","Febreiro","Marzo","Abril","Maio","Xuño","Xullo","Agosto","Setembro","Outubro","Novembro","Decembro", NullS };
static const char *my_locale_ab_month_names_gl_ES[13] =
{"Xan","Feb","Mar","Abr","Mai","Xuñ","Xul","Ago","Set","Out","Nov","Dec", NullS };
static const char *my_locale_day_names_gl_ES[8] =
{"Luns","Martes","Mércores","Xoves","Venres","Sábado","Domingo", NullS };
static const char *my_locale_ab_day_names_gl_ES[8] =
{"Lun","Mar","Mér","Xov","Ven","Sáb","Dom", NullS };
static TYPELIB my_locale_typelib_month_names_gl_ES =
{ array_elements(my_locale_month_names_gl_ES)-1, "", my_locale_month_names_gl_ES, NULL };
static TYPELIB my_locale_typelib_ab_month_names_gl_ES =
{ array_elements(my_locale_ab_month_names_gl_ES)-1, "", my_locale_ab_month_names_gl_ES, NULL };
static TYPELIB my_locale_typelib_day_names_gl_ES =
{ array_elements(my_locale_day_names_gl_ES)-1, "", my_locale_day_names_gl_ES, NULL };
static TYPELIB my_locale_typelib_ab_day_names_gl_ES =
{ array_elements(my_locale_ab_day_names_gl_ES)-1, "", my_locale_ab_day_names_gl_ES, NULL };
MY_LOCALE my_locale_gl_ES
(
22,
"gl_ES",
"Galician - Galician",
FALSE,
&my_locale_typelib_month_names_gl_ES,
&my_locale_typelib_ab_month_names_gl_ES,
&my_locale_typelib_day_names_gl_ES,
&my_locale_typelib_ab_day_names_gl_ES,
8,
8
);
/***** LOCALE END gl_ES *****/
/***** LOCALE BEGIN gu_IN: Gujarati - India *****/
static const char *my_locale_month_names_gu_IN[13] =
{"જાન્યુઆરી","ફેબ્રુઆરી","માર્ચ","એપ્રિલ","મે","જુન","જુલાઇ","ઓગસ્ટ","સેપ્ટેમ્બર","ઓક્ટોબર","નવેમ્બર","ડિસેમ્બર", NullS };
static const char *my_locale_ab_month_names_gu_IN[13] =
{"જાન","ફેબ","માર","એપ્ર","મે","જુન","જુલ","ઓગ","સેપ્ટ","ઓક્ટ","નોવ","ડિસ", NullS };
static const char *my_locale_day_names_gu_IN[8] =
{"સોમવાર","મન્ગળવાર","બુધવાર","ગુરુવાર","શુક્રવાર","શનિવાર","રવિવાર", NullS };
static const char *my_locale_ab_day_names_gu_IN[8] =
{"સોમ","મન્ગળ","બુધ","ગુરુ","શુક્ર","શનિ","રવિ", NullS };
static TYPELIB my_locale_typelib_month_names_gu_IN =
{ array_elements(my_locale_month_names_gu_IN)-1, "", my_locale_month_names_gu_IN, NULL };
static TYPELIB my_locale_typelib_ab_month_names_gu_IN =
{ array_elements(my_locale_ab_month_names_gu_IN)-1, "", my_locale_ab_month_names_gu_IN, NULL };
static TYPELIB my_locale_typelib_day_names_gu_IN =
{ array_elements(my_locale_day_names_gu_IN)-1, "", my_locale_day_names_gu_IN, NULL };
static TYPELIB my_locale_typelib_ab_day_names_gu_IN =
{ array_elements(my_locale_ab_day_names_gu_IN)-1, "", my_locale_ab_day_names_gu_IN, NULL };
MY_LOCALE my_locale_gu_IN
(
23,
"gu_IN",
"Gujarati - India",
FALSE,
&my_locale_typelib_month_names_gu_IN,
&my_locale_typelib_ab_month_names_gu_IN,
&my_locale_typelib_day_names_gu_IN,
&my_locale_typelib_ab_day_names_gu_IN,
10,
8
);
/***** LOCALE END gu_IN *****/
/***** LOCALE BEGIN he_IL: Hebrew - Israel *****/
static const char *my_locale_month_names_he_IL[13] =
{"ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר", NullS };
static const char *my_locale_ab_month_names_he_IL[13] =
{"ינו","פבר","מרץ","אפר","מאי","יונ","יול","אוג","ספט","אוק","נוב","דצמ", NullS };
static const char *my_locale_day_names_he_IL[8] =
{"שני","שלישי","רביעי","חמישי","שישי","שבת","ראשון", NullS };
static const char *my_locale_ab_day_names_he_IL[8] =
{"ב'","ג'","ד'","ה'","ו'","ש'","א'", NullS };
static TYPELIB my_locale_typelib_month_names_he_IL =
{ array_elements(my_locale_month_names_he_IL)-1, "", my_locale_month_names_he_IL, NULL };
static TYPELIB my_locale_typelib_ab_month_names_he_IL =
{ array_elements(my_locale_ab_month_names_he_IL)-1, "", my_locale_ab_month_names_he_IL, NULL };
static TYPELIB my_locale_typelib_day_names_he_IL =
{ array_elements(my_locale_day_names_he_IL)-1, "", my_locale_day_names_he_IL, NULL };
static TYPELIB my_locale_typelib_ab_day_names_he_IL =
{ array_elements(my_locale_ab_day_names_he_IL)-1, "", my_locale_ab_day_names_he_IL, NULL };
MY_LOCALE my_locale_he_IL
(
24,
"he_IL",
"Hebrew - Israel",
FALSE,
&my_locale_typelib_month_names_he_IL,
&my_locale_typelib_ab_month_names_he_IL,
&my_locale_typelib_day_names_he_IL,
&my_locale_typelib_ab_day_names_he_IL,
7,
5
);
/***** LOCALE END he_IL *****/
/***** LOCALE BEGIN hi_IN: Hindi - India *****/
static const char *my_locale_month_names_hi_IN[13] =
{"जनवरी","फ़रवरी","मार्च","अप्रेल","मई","जून","जुलाई","अगस्त","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर", NullS };
static const char *my_locale_ab_month_names_hi_IN[13] =
{"जनवरी","फ़रवरी","मार्च","अप्रेल","मई","जून","जुलाई","अगस्त","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर", NullS };
static const char *my_locale_day_names_hi_IN[8] =
{"सोमवार ","मंगलवार ","बुधवार ","गुरुवार ","शुक्रवार ","शनिवार ","रविवार ", NullS };
static const char *my_locale_ab_day_names_hi_IN[8] =
{"सोम ","मंगल ","बुध ","गुरु ","शुक्र ","शनि ","रवि ", NullS };
static TYPELIB my_locale_typelib_month_names_hi_IN =
{ array_elements(my_locale_month_names_hi_IN)-1, "", my_locale_month_names_hi_IN, NULL };
static TYPELIB my_locale_typelib_ab_month_names_hi_IN =
{ array_elements(my_locale_ab_month_names_hi_IN)-1, "", my_locale_ab_month_names_hi_IN, NULL };
static TYPELIB my_locale_typelib_day_names_hi_IN =
{ array_elements(my_locale_day_names_hi_IN)-1, "", my_locale_day_names_hi_IN, NULL };
static TYPELIB my_locale_typelib_ab_day_names_hi_IN =
{ array_elements(my_locale_ab_day_names_hi_IN)-1, "", my_locale_ab_day_names_hi_IN, NULL };
MY_LOCALE my_locale_hi_IN
(
25,
"hi_IN",
"Hindi - India",
FALSE,
&my_locale_typelib_month_names_hi_IN,
&my_locale_typelib_ab_month_names_hi_IN,
&my_locale_typelib_day_names_hi_IN,
&my_locale_typelib_ab_day_names_hi_IN,
7,
9
);
/***** LOCALE END hi_IN *****/
/***** LOCALE BEGIN hr_HR: Croatian - Croatia *****/
static const char *my_locale_month_names_hr_HR[13] =
{"Siječanj","Veljača","Ožujak","Travanj","Svibanj","Lipanj","Srpanj","Kolovoz","Rujan","Listopad","Studeni","Prosinac", NullS };
static const char *my_locale_ab_month_names_hr_HR[13] =
{"Sij","Vel","Ožu","Tra","Svi","Lip","Srp","Kol","Ruj","Lis","Stu","Pro", NullS };
static const char *my_locale_day_names_hr_HR[8] =
{"Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota","Nedjelja", NullS };
static const char *my_locale_ab_day_names_hr_HR[8] =
{"Pon","Uto","Sri","Čet","Pet","Sub","Ned", NullS };
static TYPELIB my_locale_typelib_month_names_hr_HR =
{ array_elements(my_locale_month_names_hr_HR)-1, "", my_locale_month_names_hr_HR, NULL };
static TYPELIB my_locale_typelib_ab_month_names_hr_HR =
{ array_elements(my_locale_ab_month_names_hr_HR)-1, "", my_locale_ab_month_names_hr_HR, NULL };
static TYPELIB my_locale_typelib_day_names_hr_HR =
{ array_elements(my_locale_day_names_hr_HR)-1, "", my_locale_day_names_hr_HR, NULL };
static TYPELIB my_locale_typelib_ab_day_names_hr_HR =
{ array_elements(my_locale_ab_day_names_hr_HR)-1, "", my_locale_ab_day_names_hr_HR, NULL };
MY_LOCALE my_locale_hr_HR
(
26,
"hr_HR",
"Croatian - Croatia",
FALSE,
&my_locale_typelib_month_names_hr_HR,
&my_locale_typelib_ab_month_names_hr_HR,
&my_locale_typelib_day_names_hr_HR,
&my_locale_typelib_ab_day_names_hr_HR,
8,
11
);
/***** LOCALE END hr_HR *****/
/***** LOCALE BEGIN hu_HU: Hungarian - Hungary *****/
static const char *my_locale_month_names_hu_HU[13] =
{"január","február","március","április","május","június","július","augusztus","szeptember","október","november","december", NullS };
static const char *my_locale_ab_month_names_hu_HU[13] =
{"jan","feb","már","ápr","máj","jún","júl","aug","sze","okt","nov","dec", NullS };
static const char *my_locale_day_names_hu_HU[8] =
{"hétfő","kedd","szerda","csütörtök","péntek","szombat","vasárnap", NullS };
static const char *my_locale_ab_day_names_hu_HU[8] =
{"h","k","sze","cs","p","szo","v", NullS };
static TYPELIB my_locale_typelib_month_names_hu_HU =
{ array_elements(my_locale_month_names_hu_HU)-1, "", my_locale_month_names_hu_HU, NULL };
static TYPELIB my_locale_typelib_ab_month_names_hu_HU =
{ array_elements(my_locale_ab_month_names_hu_HU)-1, "", my_locale_ab_month_names_hu_HU, NULL };
static TYPELIB my_locale_typelib_day_names_hu_HU =
{ array_elements(my_locale_day_names_hu_HU)-1, "", my_locale_day_names_hu_HU, NULL };
static TYPELIB my_locale_typelib_ab_day_names_hu_HU =
{ array_elements(my_locale_ab_day_names_hu_HU)-1, "", my_locale_ab_day_names_hu_HU, NULL };
MY_LOCALE my_locale_hu_HU
(
27,
"hu_HU",
"Hungarian - Hungary",
FALSE,
&my_locale_typelib_month_names_hu_HU,
&my_locale_typelib_ab_month_names_hu_HU,
&my_locale_typelib_day_names_hu_HU,
&my_locale_typelib_ab_day_names_hu_HU,
10,
9
);
/***** LOCALE END hu_HU *****/
/***** LOCALE BEGIN id_ID: Indonesian - Indonesia *****/
static const char *my_locale_month_names_id_ID[13] =
{"Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember", NullS };
static const char *my_locale_ab_month_names_id_ID[13] =
{"Jan","Peb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des", NullS };
static const char *my_locale_day_names_id_ID[8] =
{"Senin","Selasa","Rabu","Kamis","Jumat","Sabtu","Minggu", NullS };
static const char *my_locale_ab_day_names_id_ID[8] =
{"Sen","Sel","Rab","Kam","Jum","Sab","Min", NullS };
static TYPELIB my_locale_typelib_month_names_id_ID =
{ array_elements(my_locale_month_names_id_ID)-1, "", my_locale_month_names_id_ID, NULL };
static TYPELIB my_locale_typelib_ab_month_names_id_ID =
{ array_elements(my_locale_ab_month_names_id_ID)-1, "", my_locale_ab_month_names_id_ID, NULL };
static TYPELIB my_locale_typelib_day_names_id_ID =
{ array_elements(my_locale_day_names_id_ID)-1, "", my_locale_day_names_id_ID, NULL };
static TYPELIB my_locale_typelib_ab_day_names_id_ID =
{ array_elements(my_locale_ab_day_names_id_ID)-1, "", my_locale_ab_day_names_id_ID, NULL };
MY_LOCALE my_locale_id_ID
(
28,
"id_ID",
"Indonesian - Indonesia",
TRUE,
&my_locale_typelib_month_names_id_ID,
&my_locale_typelib_ab_month_names_id_ID,
&my_locale_typelib_day_names_id_ID,
&my_locale_typelib_ab_day_names_id_ID,
9,
6
);
/***** LOCALE END id_ID *****/
/***** LOCALE BEGIN is_IS: Icelandic - Iceland *****/
static const char *my_locale_month_names_is_IS[13] =
{"janúar","febrúar","mars","apríl","maí","júní","júlí","ágúst","september","október","nóvember","desember", NullS };
static const char *my_locale_ab_month_names_is_IS[13] =
{"jan","feb","mar","apr","maí","jún","júl","ágú","sep","okt","nóv","des", NullS };
static const char *my_locale_day_names_is_IS[8] =
{"mánudagur","þriðjudagur","miðvikudagur","fimmtudagur","föstudagur","laugardagur","sunnudagur", NullS };
static const char *my_locale_ab_day_names_is_IS[8] =
{"mán","þri","mið","fim","fös","lau","sun", NullS };
static TYPELIB my_locale_typelib_month_names_is_IS =
{ array_elements(my_locale_month_names_is_IS)-1, "", my_locale_month_names_is_IS, NULL };
static TYPELIB my_locale_typelib_ab_month_names_is_IS =
{ array_elements(my_locale_ab_month_names_is_IS)-1, "", my_locale_ab_month_names_is_IS, NULL };
static TYPELIB my_locale_typelib_day_names_is_IS =
{ array_elements(my_locale_day_names_is_IS)-1, "", my_locale_day_names_is_IS, NULL };
static TYPELIB my_locale_typelib_ab_day_names_is_IS =
{ array_elements(my_locale_ab_day_names_is_IS)-1, "", my_locale_ab_day_names_is_IS, NULL };
MY_LOCALE my_locale_is_IS
(
29,
"is_IS",
"Icelandic - Iceland",
FALSE,
&my_locale_typelib_month_names_is_IS,
&my_locale_typelib_ab_month_names_is_IS,
&my_locale_typelib_day_names_is_IS,
&my_locale_typelib_ab_day_names_is_IS,
9,
12
);
/***** LOCALE END is_IS *****/
/***** LOCALE BEGIN it_CH: Italian - Switzerland *****/
static const char *my_locale_month_names_it_CH[13] =
{"gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre", NullS };
static const char *my_locale_ab_month_names_it_CH[13] =
{"gen","feb","mar","apr","mag","giu","lug","ago","set","ott","nov","dic", NullS };
static const char *my_locale_day_names_it_CH[8] =
{"lunedì","martedì","mercoledì","giovedì","venerdì","sabato","domenica", NullS };
static const char *my_locale_ab_day_names_it_CH[8] =
{"lun","mar","mer","gio","ven","sab","dom", NullS };
static TYPELIB my_locale_typelib_month_names_it_CH =
{ array_elements(my_locale_month_names_it_CH)-1, "", my_locale_month_names_it_CH, NULL };
static TYPELIB my_locale_typelib_ab_month_names_it_CH =
{ array_elements(my_locale_ab_month_names_it_CH)-1, "", my_locale_ab_month_names_it_CH, NULL };
static TYPELIB my_locale_typelib_day_names_it_CH =
{ array_elements(my_locale_day_names_it_CH)-1, "", my_locale_day_names_it_CH, NULL };
static TYPELIB my_locale_typelib_ab_day_names_it_CH =
{ array_elements(my_locale_ab_day_names_it_CH)-1, "", my_locale_ab_day_names_it_CH, NULL };
MY_LOCALE my_locale_it_CH
(
30,
"it_CH",
"Italian - Switzerland",
FALSE,
&my_locale_typelib_month_names_it_CH,
&my_locale_typelib_ab_month_names_it_CH,
&my_locale_typelib_day_names_it_CH,
&my_locale_typelib_ab_day_names_it_CH,
9,
9
);
/***** LOCALE END it_CH *****/
/***** LOCALE BEGIN ja_JP: Japanese - Japan *****/
static const char *my_locale_month_names_ja_JP[13] =
{"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月", NullS };
static const char *my_locale_ab_month_names_ja_JP[13] =
{" 1月"," 2月"," 3月"," 4月"," 5月"," 6月"," 7月"," 8月"," 9月","10月","11月","12月", NullS };
static const char *my_locale_day_names_ja_JP[8] =
{"月曜日","火曜日","水曜日","木曜日","金曜日","土曜日","日曜日", NullS };
static const char *my_locale_ab_day_names_ja_JP[8] =
{"月","火","水","木","金","土","日", NullS };
static TYPELIB my_locale_typelib_month_names_ja_JP =
{ array_elements(my_locale_month_names_ja_JP)-1, "", my_locale_month_names_ja_JP, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ja_JP =
{ array_elements(my_locale_ab_month_names_ja_JP)-1, "", my_locale_ab_month_names_ja_JP, NULL };
static TYPELIB my_locale_typelib_day_names_ja_JP =
{ array_elements(my_locale_day_names_ja_JP)-1, "", my_locale_day_names_ja_JP, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ja_JP =
{ array_elements(my_locale_ab_day_names_ja_JP)-1, "", my_locale_ab_day_names_ja_JP, NULL };
MY_LOCALE my_locale_ja_JP
(
2,
"ja_JP",
"Japanese - Japan",
FALSE,
&my_locale_typelib_month_names_ja_JP,
&my_locale_typelib_ab_month_names_ja_JP,
&my_locale_typelib_day_names_ja_JP,
&my_locale_typelib_ab_day_names_ja_JP,
3,
3
);
/***** LOCALE END ja_JP *****/
/***** LOCALE BEGIN ko_KR: Korean - Korea *****/
static const char *my_locale_month_names_ko_KR[13] =
{"일월","이월","삼월","사월","오월","유월","칠월","팔월","구월","시월","십일월","십이월", NullS };
static const char *my_locale_ab_month_names_ko_KR[13] =
{" 1월"," 2월"," 3월"," 4월"," 5월"," 6월"," 7월"," 8월"," 9월","10월","11월","12월", NullS };
static const char *my_locale_day_names_ko_KR[8] =
{"월요일","화요일","수요일","목요일","금요일","토요일","일요일", NullS };
static const char *my_locale_ab_day_names_ko_KR[8] =
{"월","화","수","목","금","토","일", NullS };
static TYPELIB my_locale_typelib_month_names_ko_KR =
{ array_elements(my_locale_month_names_ko_KR)-1, "", my_locale_month_names_ko_KR, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ko_KR =
{ array_elements(my_locale_ab_month_names_ko_KR)-1, "", my_locale_ab_month_names_ko_KR, NULL };
static TYPELIB my_locale_typelib_day_names_ko_KR =
{ array_elements(my_locale_day_names_ko_KR)-1, "", my_locale_day_names_ko_KR, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ko_KR =
{ array_elements(my_locale_ab_day_names_ko_KR)-1, "", my_locale_ab_day_names_ko_KR, NULL };
MY_LOCALE my_locale_ko_KR
(
31,
"ko_KR",
"Korean - Korea",
FALSE,
&my_locale_typelib_month_names_ko_KR,
&my_locale_typelib_ab_month_names_ko_KR,
&my_locale_typelib_day_names_ko_KR,
&my_locale_typelib_ab_day_names_ko_KR,
3,
3
);
/***** LOCALE END ko_KR *****/
/***** LOCALE BEGIN lt_LT: Lithuanian - Lithuania *****/
static const char *my_locale_month_names_lt_LT[13] =
{"sausio","vasario","kovo","balandžio","gegužės","birželio","liepos","rugpjūčio","rugsėjo","spalio","lapkričio","gruodžio", NullS };
static const char *my_locale_ab_month_names_lt_LT[13] =
{"Sau","Vas","Kov","Bal","Geg","Bir","Lie","Rgp","Rgs","Spa","Lap","Grd", NullS };
static const char *my_locale_day_names_lt_LT[8] =
{"Pirmadienis","Antradienis","Trečiadienis","Ketvirtadienis","Penktadienis","Šeštadienis","Sekmadienis", NullS };
static const char *my_locale_ab_day_names_lt_LT[8] =
{"Pr","An","Tr","Kt","Pn","Št","Sk", NullS };
static TYPELIB my_locale_typelib_month_names_lt_LT =
{ array_elements(my_locale_month_names_lt_LT)-1, "", my_locale_month_names_lt_LT, NULL };
static TYPELIB my_locale_typelib_ab_month_names_lt_LT =
{ array_elements(my_locale_ab_month_names_lt_LT)-1, "", my_locale_ab_month_names_lt_LT, NULL };
static TYPELIB my_locale_typelib_day_names_lt_LT =
{ array_elements(my_locale_day_names_lt_LT)-1, "", my_locale_day_names_lt_LT, NULL };
static TYPELIB my_locale_typelib_ab_day_names_lt_LT =
{ array_elements(my_locale_ab_day_names_lt_LT)-1, "", my_locale_ab_day_names_lt_LT, NULL };
MY_LOCALE my_locale_lt_LT
(
32,
"lt_LT",
"Lithuanian - Lithuania",
FALSE,
&my_locale_typelib_month_names_lt_LT,
&my_locale_typelib_ab_month_names_lt_LT,
&my_locale_typelib_day_names_lt_LT,
&my_locale_typelib_ab_day_names_lt_LT,
9,
14
);
/***** LOCALE END lt_LT *****/
/***** LOCALE BEGIN lv_LV: Latvian - Latvia *****/
static const char *my_locale_month_names_lv_LV[13] =
{"janvāris","februāris","marts","aprīlis","maijs","jūnijs","jūlijs","augusts","septembris","oktobris","novembris","decembris", NullS };
static const char *my_locale_ab_month_names_lv_LV[13] =
{"jan","feb","mar","apr","mai","jūn","jūl","aug","sep","okt","nov","dec", NullS };
static const char *my_locale_day_names_lv_LV[8] =
{"pirmdiena","otrdiena","trešdiena","ceturtdiena","piektdiena","sestdiena","svētdiena", NullS };
static const char *my_locale_ab_day_names_lv_LV[8] =
{"P ","O ","T ","C ","Pk","S ","Sv", NullS };
static TYPELIB my_locale_typelib_month_names_lv_LV =
{ array_elements(my_locale_month_names_lv_LV)-1, "", my_locale_month_names_lv_LV, NULL };
static TYPELIB my_locale_typelib_ab_month_names_lv_LV =
{ array_elements(my_locale_ab_month_names_lv_LV)-1, "", my_locale_ab_month_names_lv_LV, NULL };
static TYPELIB my_locale_typelib_day_names_lv_LV =
{ array_elements(my_locale_day_names_lv_LV)-1, "", my_locale_day_names_lv_LV, NULL };
static TYPELIB my_locale_typelib_ab_day_names_lv_LV =
{ array_elements(my_locale_ab_day_names_lv_LV)-1, "", my_locale_ab_day_names_lv_LV, NULL };
MY_LOCALE my_locale_lv_LV
(
33,
"lv_LV",
"Latvian - Latvia",
FALSE,
&my_locale_typelib_month_names_lv_LV,
&my_locale_typelib_ab_month_names_lv_LV,
&my_locale_typelib_day_names_lv_LV,
&my_locale_typelib_ab_day_names_lv_LV,
10,
11
);
/***** LOCALE END lv_LV *****/
/***** LOCALE BEGIN mk_MK: Macedonian - FYROM *****/
static const char *my_locale_month_names_mk_MK[13] =
{"јануари","февруари","март","април","мај","јуни","јули","август","септември","октомври","ноември","декември", NullS };
static const char *my_locale_ab_month_names_mk_MK[13] =
{"јан","фев","мар","апр","мај","јун","јул","авг","сеп","окт","ное","дек", NullS };
static const char *my_locale_day_names_mk_MK[8] =
{"понеделник","вторник","среда","четврток","петок","сабота","недела", NullS };
static const char *my_locale_ab_day_names_mk_MK[8] =
{"пон","вто","сре","чет","пет","саб","нед", NullS };
static TYPELIB my_locale_typelib_month_names_mk_MK =
{ array_elements(my_locale_month_names_mk_MK)-1, "", my_locale_month_names_mk_MK, NULL };
static TYPELIB my_locale_typelib_ab_month_names_mk_MK =
{ array_elements(my_locale_ab_month_names_mk_MK)-1, "", my_locale_ab_month_names_mk_MK, NULL };
static TYPELIB my_locale_typelib_day_names_mk_MK =
{ array_elements(my_locale_day_names_mk_MK)-1, "", my_locale_day_names_mk_MK, NULL };
static TYPELIB my_locale_typelib_ab_day_names_mk_MK =
{ array_elements(my_locale_ab_day_names_mk_MK)-1, "", my_locale_ab_day_names_mk_MK, NULL };
MY_LOCALE my_locale_mk_MK
(
34,
"mk_MK",
"Macedonian - FYROM",
FALSE,
&my_locale_typelib_month_names_mk_MK,
&my_locale_typelib_ab_month_names_mk_MK,
&my_locale_typelib_day_names_mk_MK,
&my_locale_typelib_ab_day_names_mk_MK,
9,
10
);
/***** LOCALE END mk_MK *****/
/***** LOCALE BEGIN mn_MN: Mongolia - Mongolian *****/
static const char *my_locale_month_names_mn_MN[13] =
{"Нэгдүгээр сар","Хоёрдугаар сар","Гуравдугаар сар","Дөрөвдүгээр сар","Тавдугаар сар","Зургаадугар сар","Долоодугаар сар","Наймдугаар сар","Есдүгээр сар","Аравдугаар сар","Арваннэгдүгээр сар","Арванхоёрдгаар сар", NullS };
static const char *my_locale_ab_month_names_mn_MN[13] =
{"1-р","2-р","3-р","4-р","5-р","6-р","7-р","8-р","9-р","10-р","11-р","12-р", NullS };
static const char *my_locale_day_names_mn_MN[8] =
{"Даваа","Мягмар","Лхагва","Пүрэв","Баасан","Бямба","Ням", NullS };
static const char *my_locale_ab_day_names_mn_MN[8] =
{"Да","Мя","Лх","Пү","Ба","Бя","Ня", NullS };
static TYPELIB my_locale_typelib_month_names_mn_MN =
{ array_elements(my_locale_month_names_mn_MN)-1, "", my_locale_month_names_mn_MN, NULL };
static TYPELIB my_locale_typelib_ab_month_names_mn_MN =
{ array_elements(my_locale_ab_month_names_mn_MN)-1, "", my_locale_ab_month_names_mn_MN, NULL };
static TYPELIB my_locale_typelib_day_names_mn_MN =
{ array_elements(my_locale_day_names_mn_MN)-1, "", my_locale_day_names_mn_MN, NULL };
static TYPELIB my_locale_typelib_ab_day_names_mn_MN =
{ array_elements(my_locale_ab_day_names_mn_MN)-1, "", my_locale_ab_day_names_mn_MN, NULL };
MY_LOCALE my_locale_mn_MN
(
35,
"mn_MN",
"Mongolia - Mongolian",
FALSE,
&my_locale_typelib_month_names_mn_MN,
&my_locale_typelib_ab_month_names_mn_MN,
&my_locale_typelib_day_names_mn_MN,
&my_locale_typelib_ab_day_names_mn_MN,
18,
6
);
/***** LOCALE END mn_MN *****/
/***** LOCALE BEGIN ms_MY: Malay - Malaysia *****/
static const char *my_locale_month_names_ms_MY[13] =
{"Januari","Februari","Mac","April","Mei","Jun","Julai","Ogos","September","Oktober","November","Disember", NullS };
static const char *my_locale_ab_month_names_ms_MY[13] =
{"Jan","Feb","Mac","Apr","Mei","Jun","Jul","Ogos","Sep","Okt","Nov","Dis", NullS };
static const char *my_locale_day_names_ms_MY[8] =
{"Isnin","Selasa","Rabu","Khamis","Jumaat","Sabtu","Ahad", NullS };
static const char *my_locale_ab_day_names_ms_MY[8] =
{"Isn","Sel","Rab","Kha","Jum","Sab","Ahd", NullS };
static TYPELIB my_locale_typelib_month_names_ms_MY =
{ array_elements(my_locale_month_names_ms_MY)-1, "", my_locale_month_names_ms_MY, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ms_MY =
{ array_elements(my_locale_ab_month_names_ms_MY)-1, "", my_locale_ab_month_names_ms_MY, NULL };
static TYPELIB my_locale_typelib_day_names_ms_MY =
{ array_elements(my_locale_day_names_ms_MY)-1, "", my_locale_day_names_ms_MY, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ms_MY =
{ array_elements(my_locale_ab_day_names_ms_MY)-1, "", my_locale_ab_day_names_ms_MY, NULL };
MY_LOCALE my_locale_ms_MY
(
36,
"ms_MY",
"Malay - Malaysia",
TRUE,
&my_locale_typelib_month_names_ms_MY,
&my_locale_typelib_ab_month_names_ms_MY,
&my_locale_typelib_day_names_ms_MY,
&my_locale_typelib_ab_day_names_ms_MY,
9,
6
);
/***** LOCALE END ms_MY *****/
/***** LOCALE BEGIN nb_NO: Norwegian(Bokml) - Norway *****/
static const char *my_locale_month_names_nb_NO[13] =
{"januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember", NullS };
static const char *my_locale_ab_month_names_nb_NO[13] =
{"jan","feb","mar","apr","mai","jun","jul","aug","sep","okt","nov","des", NullS };
static const char *my_locale_day_names_nb_NO[8] =
{"mandag","tirsdag","onsdag","torsdag","fredag","lørdag","søndag", NullS };
static const char *my_locale_ab_day_names_nb_NO[8] =
{"man","tir","ons","tor","fre","lør","søn", NullS };
static TYPELIB my_locale_typelib_month_names_nb_NO =
{ array_elements(my_locale_month_names_nb_NO)-1, "", my_locale_month_names_nb_NO, NULL };
static TYPELIB my_locale_typelib_ab_month_names_nb_NO =
{ array_elements(my_locale_ab_month_names_nb_NO)-1, "", my_locale_ab_month_names_nb_NO, NULL };
static TYPELIB my_locale_typelib_day_names_nb_NO =
{ array_elements(my_locale_day_names_nb_NO)-1, "", my_locale_day_names_nb_NO, NULL };
static TYPELIB my_locale_typelib_ab_day_names_nb_NO =
{ array_elements(my_locale_ab_day_names_nb_NO)-1, "", my_locale_ab_day_names_nb_NO, NULL };
MY_LOCALE my_locale_nb_NO
(
37,
"nb_NO",
"Norwegian(Bokml) - Norway",
FALSE,
&my_locale_typelib_month_names_nb_NO,
&my_locale_typelib_ab_month_names_nb_NO,
&my_locale_typelib_day_names_nb_NO,
&my_locale_typelib_ab_day_names_nb_NO,
9,
7
);
/***** LOCALE END nb_NO *****/
/***** LOCALE BEGIN nl_NL: Dutch - The Netherlands *****/
static const char *my_locale_month_names_nl_NL[13] =
{"januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december", NullS };
static const char *my_locale_ab_month_names_nl_NL[13] =
{"jan","feb","mrt","apr","mei","jun","jul","aug","sep","okt","nov","dec", NullS };
static const char *my_locale_day_names_nl_NL[8] =
{"maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag","zondag", NullS };
static const char *my_locale_ab_day_names_nl_NL[8] =
{"ma","di","wo","do","vr","za","zo", NullS };
static TYPELIB my_locale_typelib_month_names_nl_NL =
{ array_elements(my_locale_month_names_nl_NL)-1, "", my_locale_month_names_nl_NL, NULL };
static TYPELIB my_locale_typelib_ab_month_names_nl_NL =
{ array_elements(my_locale_ab_month_names_nl_NL)-1, "", my_locale_ab_month_names_nl_NL, NULL };
static TYPELIB my_locale_typelib_day_names_nl_NL =
{ array_elements(my_locale_day_names_nl_NL)-1, "", my_locale_day_names_nl_NL, NULL };
static TYPELIB my_locale_typelib_ab_day_names_nl_NL =
{ array_elements(my_locale_ab_day_names_nl_NL)-1, "", my_locale_ab_day_names_nl_NL, NULL };
MY_LOCALE my_locale_nl_NL
(
38,
"nl_NL",
"Dutch - The Netherlands",
TRUE,
&my_locale_typelib_month_names_nl_NL,
&my_locale_typelib_ab_month_names_nl_NL,
&my_locale_typelib_day_names_nl_NL,
&my_locale_typelib_ab_day_names_nl_NL,
9,
9
);
/***** LOCALE END nl_NL *****/
/***** LOCALE BEGIN pl_PL: Polish - Poland *****/
static const char *my_locale_month_names_pl_PL[13] =
{"styczeń","luty","marzec","kwiecień","maj","czerwiec","lipiec","sierpień","wrzesień","październik","listopad","grudzień", NullS };
static const char *my_locale_ab_month_names_pl_PL[13] =
{"sty","lut","mar","kwi","maj","cze","lip","sie","wrz","paź","lis","gru", NullS };
static const char *my_locale_day_names_pl_PL[8] =
{"poniedziałek","wtorek","środa","czwartek","piątek","sobota","niedziela", NullS };
static const char *my_locale_ab_day_names_pl_PL[8] =
{"pon","wto","śro","czw","pią","sob","nie", NullS };
static TYPELIB my_locale_typelib_month_names_pl_PL =
{ array_elements(my_locale_month_names_pl_PL)-1, "", my_locale_month_names_pl_PL, NULL };
static TYPELIB my_locale_typelib_ab_month_names_pl_PL =
{ array_elements(my_locale_ab_month_names_pl_PL)-1, "", my_locale_ab_month_names_pl_PL, NULL };
static TYPELIB my_locale_typelib_day_names_pl_PL =
{ array_elements(my_locale_day_names_pl_PL)-1, "", my_locale_day_names_pl_PL, NULL };
static TYPELIB my_locale_typelib_ab_day_names_pl_PL =
{ array_elements(my_locale_ab_day_names_pl_PL)-1, "", my_locale_ab_day_names_pl_PL, NULL };
MY_LOCALE my_locale_pl_PL
(
39,
"pl_PL",
"Polish - Poland",
FALSE,
&my_locale_typelib_month_names_pl_PL,
&my_locale_typelib_ab_month_names_pl_PL,
&my_locale_typelib_day_names_pl_PL,
&my_locale_typelib_ab_day_names_pl_PL,
11,
12
);
/***** LOCALE END pl_PL *****/
/***** LOCALE BEGIN pt_BR: Portugese - Brazil *****/
static const char *my_locale_month_names_pt_BR[13] =
{"janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro", NullS };
static const char *my_locale_ab_month_names_pt_BR[13] =
{"Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez", NullS };
static const char *my_locale_day_names_pt_BR[8] =
{"segunda","terça","quarta","quinta","sexta","sábado","domingo", NullS };
static const char *my_locale_ab_day_names_pt_BR[8] =
{"Seg","Ter","Qua","Qui","Sex","Sáb","Dom", NullS };
static TYPELIB my_locale_typelib_month_names_pt_BR =
{ array_elements(my_locale_month_names_pt_BR)-1, "", my_locale_month_names_pt_BR, NULL };
static TYPELIB my_locale_typelib_ab_month_names_pt_BR =
{ array_elements(my_locale_ab_month_names_pt_BR)-1, "", my_locale_ab_month_names_pt_BR, NULL };
static TYPELIB my_locale_typelib_day_names_pt_BR =
{ array_elements(my_locale_day_names_pt_BR)-1, "", my_locale_day_names_pt_BR, NULL };
static TYPELIB my_locale_typelib_ab_day_names_pt_BR =
{ array_elements(my_locale_ab_day_names_pt_BR)-1, "", my_locale_ab_day_names_pt_BR, NULL };
MY_LOCALE my_locale_pt_BR
(
40,
"pt_BR",
"Portugese - Brazil",
FALSE,
&my_locale_typelib_month_names_pt_BR,
&my_locale_typelib_ab_month_names_pt_BR,
&my_locale_typelib_day_names_pt_BR,
&my_locale_typelib_ab_day_names_pt_BR,
9,
7
);
/***** LOCALE END pt_BR *****/
/***** LOCALE BEGIN pt_PT: Portugese - Portugal *****/
static const char *my_locale_month_names_pt_PT[13] =
{"Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro", NullS };
static const char *my_locale_ab_month_names_pt_PT[13] =
{"Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez", NullS };
static const char *my_locale_day_names_pt_PT[8] =
{"Segunda","Terça","Quarta","Quinta","Sexta","Sábado","Domingo", NullS };
static const char *my_locale_ab_day_names_pt_PT[8] =
{"Seg","Ter","Qua","Qui","Sex","Sáb","Dom", NullS };
static TYPELIB my_locale_typelib_month_names_pt_PT =
{ array_elements(my_locale_month_names_pt_PT)-1, "", my_locale_month_names_pt_PT, NULL };
static TYPELIB my_locale_typelib_ab_month_names_pt_PT =
{ array_elements(my_locale_ab_month_names_pt_PT)-1, "", my_locale_ab_month_names_pt_PT, NULL };
static TYPELIB my_locale_typelib_day_names_pt_PT =
{ array_elements(my_locale_day_names_pt_PT)-1, "", my_locale_day_names_pt_PT, NULL };
static TYPELIB my_locale_typelib_ab_day_names_pt_PT =
{ array_elements(my_locale_ab_day_names_pt_PT)-1, "", my_locale_ab_day_names_pt_PT, NULL };
MY_LOCALE my_locale_pt_PT
(
41,
"pt_PT",
"Portugese - Portugal",
FALSE,
&my_locale_typelib_month_names_pt_PT,
&my_locale_typelib_ab_month_names_pt_PT,
&my_locale_typelib_day_names_pt_PT,
&my_locale_typelib_ab_day_names_pt_PT,
9,
7
);
/***** LOCALE END pt_PT *****/
/***** LOCALE BEGIN ro_RO: Romanian - Romania *****/
static const char *my_locale_month_names_ro_RO[13] =
{"Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie", NullS };
static const char *my_locale_ab_month_names_ro_RO[13] =
{"ian","feb","mar","apr","mai","iun","iul","aug","sep","oct","nov","dec", NullS };
static const char *my_locale_day_names_ro_RO[8] =
{"Luni","Marţi","Miercuri","Joi","Vineri","Sâmbătă","Duminică", NullS };
static const char *my_locale_ab_day_names_ro_RO[8] =
{"Lu","Ma","Mi","Jo","Vi","Sâ","Du", NullS };
static TYPELIB my_locale_typelib_month_names_ro_RO =
{ array_elements(my_locale_month_names_ro_RO)-1, "", my_locale_month_names_ro_RO, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ro_RO =
{ array_elements(my_locale_ab_month_names_ro_RO)-1, "", my_locale_ab_month_names_ro_RO, NULL };
static TYPELIB my_locale_typelib_day_names_ro_RO =
{ array_elements(my_locale_day_names_ro_RO)-1, "", my_locale_day_names_ro_RO, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ro_RO =
{ array_elements(my_locale_ab_day_names_ro_RO)-1, "", my_locale_ab_day_names_ro_RO, NULL };
MY_LOCALE my_locale_ro_RO
(
42,
"ro_RO",
"Romanian - Romania",
FALSE,
&my_locale_typelib_month_names_ro_RO,
&my_locale_typelib_ab_month_names_ro_RO,
&my_locale_typelib_day_names_ro_RO,
&my_locale_typelib_ab_day_names_ro_RO,
10,
8
);
/***** LOCALE END ro_RO *****/
/***** LOCALE BEGIN ru_RU: Russian - Russia *****/
static const char *my_locale_month_names_ru_RU[13] =
{"Января","Февраля","Марта","Апреля","Мая","Июня","Июля","Августа","Сентября","Октября","Ноября","Декабря", NullS };
static const char *my_locale_ab_month_names_ru_RU[13] =
{"Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек", NullS };
static const char *my_locale_day_names_ru_RU[8] =
{"Понедельник","Вторник","Среда","Четверг","Пятница","Суббота","Воскресенье", NullS };
static const char *my_locale_ab_day_names_ru_RU[8] =
{"Пнд","Втр","Срд","Чтв","Птн","Сбт","Вск", NullS };
static TYPELIB my_locale_typelib_month_names_ru_RU =
{ array_elements(my_locale_month_names_ru_RU)-1, "", my_locale_month_names_ru_RU, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ru_RU =
{ array_elements(my_locale_ab_month_names_ru_RU)-1, "", my_locale_ab_month_names_ru_RU, NULL };
static TYPELIB my_locale_typelib_day_names_ru_RU =
{ array_elements(my_locale_day_names_ru_RU)-1, "", my_locale_day_names_ru_RU, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ru_RU =
{ array_elements(my_locale_ab_day_names_ru_RU)-1, "", my_locale_ab_day_names_ru_RU, NULL };
MY_LOCALE my_locale_ru_RU
(
43,
"ru_RU",
"Russian - Russia",
FALSE,
&my_locale_typelib_month_names_ru_RU,
&my_locale_typelib_ab_month_names_ru_RU,
&my_locale_typelib_day_names_ru_RU,
&my_locale_typelib_ab_day_names_ru_RU,
8,
11
);
/***** LOCALE END ru_RU *****/
/***** LOCALE BEGIN ru_UA: Russian - Ukraine *****/
static const char *my_locale_month_names_ru_UA[13] =
{"Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь", NullS };
static const char *my_locale_ab_month_names_ru_UA[13] =
{"Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек", NullS };
static const char *my_locale_day_names_ru_UA[8] =
{"Понедельник","Вторник","Среда","Четверг","Пятница","Суббота","Воскресенье", NullS };
static const char *my_locale_ab_day_names_ru_UA[8] =
{"Пнд","Вто","Срд","Чтв","Птн","Суб","Вск", NullS };
static TYPELIB my_locale_typelib_month_names_ru_UA =
{ array_elements(my_locale_month_names_ru_UA)-1, "", my_locale_month_names_ru_UA, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ru_UA =
{ array_elements(my_locale_ab_month_names_ru_UA)-1, "", my_locale_ab_month_names_ru_UA, NULL };
static TYPELIB my_locale_typelib_day_names_ru_UA =
{ array_elements(my_locale_day_names_ru_UA)-1, "", my_locale_day_names_ru_UA, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ru_UA =
{ array_elements(my_locale_ab_day_names_ru_UA)-1, "", my_locale_ab_day_names_ru_UA, NULL };
MY_LOCALE my_locale_ru_UA
(
44,
"ru_UA",
"Russian - Ukraine",
FALSE,
&my_locale_typelib_month_names_ru_UA,
&my_locale_typelib_ab_month_names_ru_UA,
&my_locale_typelib_day_names_ru_UA,
&my_locale_typelib_ab_day_names_ru_UA,
8,
11
);
/***** LOCALE END ru_UA *****/
/***** LOCALE BEGIN sk_SK: Slovak - Slovakia *****/
static const char *my_locale_month_names_sk_SK[13] =
{"január","február","marec","apríl","máj","jún","júl","august","september","október","november","december", NullS };
static const char *my_locale_ab_month_names_sk_SK[13] =
{"jan","feb","mar","apr","máj","jún","júl","aug","sep","okt","nov","dec", NullS };
static const char *my_locale_day_names_sk_SK[8] =
{"Pondelok","Utorok","Streda","Štvrtok","Piatok","Sobota","Nedeľa", NullS };
static const char *my_locale_ab_day_names_sk_SK[8] =
{"Po","Ut","St","Št","Pi","So","Ne", NullS };
static TYPELIB my_locale_typelib_month_names_sk_SK =
{ array_elements(my_locale_month_names_sk_SK)-1, "", my_locale_month_names_sk_SK, NULL };
static TYPELIB my_locale_typelib_ab_month_names_sk_SK =
{ array_elements(my_locale_ab_month_names_sk_SK)-1, "", my_locale_ab_month_names_sk_SK, NULL };
static TYPELIB my_locale_typelib_day_names_sk_SK =
{ array_elements(my_locale_day_names_sk_SK)-1, "", my_locale_day_names_sk_SK, NULL };
static TYPELIB my_locale_typelib_ab_day_names_sk_SK =
{ array_elements(my_locale_ab_day_names_sk_SK)-1, "", my_locale_ab_day_names_sk_SK, NULL };
MY_LOCALE my_locale_sk_SK
(
45,
"sk_SK",
"Slovak - Slovakia",
FALSE,
&my_locale_typelib_month_names_sk_SK,
&my_locale_typelib_ab_month_names_sk_SK,
&my_locale_typelib_day_names_sk_SK,
&my_locale_typelib_ab_day_names_sk_SK,
9,
8
);
/***** LOCALE END sk_SK *****/
/***** LOCALE BEGIN sl_SI: Slovenian - Slovenia *****/
static const char *my_locale_month_names_sl_SI[13] =
{"januar","februar","marec","april","maj","junij","julij","avgust","september","oktober","november","december", NullS };
static const char *my_locale_ab_month_names_sl_SI[13] =
{"jan","feb","mar","apr","maj","jun","jul","avg","sep","okt","nov","dec", NullS };
static const char *my_locale_day_names_sl_SI[8] =
{"ponedeljek","torek","sreda","četrtek","petek","sobota","nedelja", NullS };
static const char *my_locale_ab_day_names_sl_SI[8] =
{"pon","tor","sre","čet","pet","sob","ned", NullS };
static TYPELIB my_locale_typelib_month_names_sl_SI =
{ array_elements(my_locale_month_names_sl_SI)-1, "", my_locale_month_names_sl_SI, NULL };
static TYPELIB my_locale_typelib_ab_month_names_sl_SI =
{ array_elements(my_locale_ab_month_names_sl_SI)-1, "", my_locale_ab_month_names_sl_SI, NULL };
static TYPELIB my_locale_typelib_day_names_sl_SI =
{ array_elements(my_locale_day_names_sl_SI)-1, "", my_locale_day_names_sl_SI, NULL };
static TYPELIB my_locale_typelib_ab_day_names_sl_SI =
{ array_elements(my_locale_ab_day_names_sl_SI)-1, "", my_locale_ab_day_names_sl_SI, NULL };
MY_LOCALE my_locale_sl_SI
(
46,
"sl_SI",
"Slovenian - Slovenia",
FALSE,
&my_locale_typelib_month_names_sl_SI,
&my_locale_typelib_ab_month_names_sl_SI,
&my_locale_typelib_day_names_sl_SI,
&my_locale_typelib_ab_day_names_sl_SI,
9,
10
);
/***** LOCALE END sl_SI *****/
/***** LOCALE BEGIN sq_AL: Albanian - Albania *****/
static const char *my_locale_month_names_sq_AL[13] =
{"janar","shkurt","mars","prill","maj","qershor","korrik","gusht","shtator","tetor","nëntor","dhjetor", NullS };
static const char *my_locale_ab_month_names_sq_AL[13] =
{"Jan","Shk","Mar","Pri","Maj","Qer","Kor","Gsh","Sht","Tet","Nën","Dhj", NullS };
static const char *my_locale_day_names_sq_AL[8] =
{"e hënë ","e martë ","e mërkurë ","e enjte ","e premte ","e shtunë ","e diel ", NullS };
static const char *my_locale_ab_day_names_sq_AL[8] =
{"Hën ","Mar ","Mër ","Enj ","Pre ","Sht ","Die ", NullS };
static TYPELIB my_locale_typelib_month_names_sq_AL =
{ array_elements(my_locale_month_names_sq_AL)-1, "", my_locale_month_names_sq_AL, NULL };
static TYPELIB my_locale_typelib_ab_month_names_sq_AL =
{ array_elements(my_locale_ab_month_names_sq_AL)-1, "", my_locale_ab_month_names_sq_AL, NULL };
static TYPELIB my_locale_typelib_day_names_sq_AL =
{ array_elements(my_locale_day_names_sq_AL)-1, "", my_locale_day_names_sq_AL, NULL };
static TYPELIB my_locale_typelib_ab_day_names_sq_AL =
{ array_elements(my_locale_ab_day_names_sq_AL)-1, "", my_locale_ab_day_names_sq_AL, NULL };
MY_LOCALE my_locale_sq_AL
(
47,
"sq_AL",
"Albanian - Albania",
FALSE,
&my_locale_typelib_month_names_sq_AL,
&my_locale_typelib_ab_month_names_sq_AL,
&my_locale_typelib_day_names_sq_AL,
&my_locale_typelib_ab_day_names_sq_AL,
7,
10
);
/***** LOCALE END sq_AL *****/
/***** LOCALE BEGIN sr_YU: Servian - Yugoslavia *****/
static const char *my_locale_month_names_sr_YU[13] =
{"januar","februar","mart","april","maj","juni","juli","avgust","septembar","oktobar","novembar","decembar", NullS };
static const char *my_locale_ab_month_names_sr_YU[13] =
{"jan","feb","mar","apr","maj","jun","jul","avg","sep","okt","nov","dec", NullS };
static const char *my_locale_day_names_sr_YU[8] =
{"ponedeljak","utorak","sreda","četvrtak","petak","subota","nedelja", NullS };
static const char *my_locale_ab_day_names_sr_YU[8] =
{"pon","uto","sre","čet","pet","sub","ned", NullS };
static TYPELIB my_locale_typelib_month_names_sr_YU =
{ array_elements(my_locale_month_names_sr_YU)-1, "", my_locale_month_names_sr_YU, NULL };
static TYPELIB my_locale_typelib_ab_month_names_sr_YU =
{ array_elements(my_locale_ab_month_names_sr_YU)-1, "", my_locale_ab_month_names_sr_YU, NULL };
static TYPELIB my_locale_typelib_day_names_sr_YU =
{ array_elements(my_locale_day_names_sr_YU)-1, "", my_locale_day_names_sr_YU, NULL };
static TYPELIB my_locale_typelib_ab_day_names_sr_YU =
{ array_elements(my_locale_ab_day_names_sr_YU)-1, "", my_locale_ab_day_names_sr_YU, NULL };
MY_LOCALE my_locale_sr_YU
(
48,
"sr_YU",
"Servian - Yugoslavia",
FALSE,
&my_locale_typelib_month_names_sr_YU,
&my_locale_typelib_ab_month_names_sr_YU,
&my_locale_typelib_day_names_sr_YU,
&my_locale_typelib_ab_day_names_sr_YU,
9,
10
);
/***** LOCALE END sr_YU *****/
/***** LOCALE BEGIN sv_SE: Swedish - Sweden *****/
static const char *my_locale_month_names_sv_SE[13] =
{"januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december", NullS };
static const char *my_locale_ab_month_names_sv_SE[13] =
{"jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec", NullS };
static const char *my_locale_day_names_sv_SE[8] =
{"måndag","tisdag","onsdag","torsdag","fredag","lördag","söndag", NullS };
static const char *my_locale_ab_day_names_sv_SE[8] =
{"mån","tis","ons","tor","fre","lör","sön", NullS };
static TYPELIB my_locale_typelib_month_names_sv_SE =
{ array_elements(my_locale_month_names_sv_SE)-1, "", my_locale_month_names_sv_SE, NULL };
static TYPELIB my_locale_typelib_ab_month_names_sv_SE =
{ array_elements(my_locale_ab_month_names_sv_SE)-1, "", my_locale_ab_month_names_sv_SE, NULL };
static TYPELIB my_locale_typelib_day_names_sv_SE =
{ array_elements(my_locale_day_names_sv_SE)-1, "", my_locale_day_names_sv_SE, NULL };
static TYPELIB my_locale_typelib_ab_day_names_sv_SE =
{ array_elements(my_locale_ab_day_names_sv_SE)-1, "", my_locale_ab_day_names_sv_SE, NULL };
MY_LOCALE my_locale_sv_SE
(
3,
"sv_SE",
"Swedish - Sweden",
FALSE,
&my_locale_typelib_month_names_sv_SE,
&my_locale_typelib_ab_month_names_sv_SE,
&my_locale_typelib_day_names_sv_SE,
&my_locale_typelib_ab_day_names_sv_SE,
9,
7
);
/***** LOCALE END sv_SE *****/
/***** LOCALE BEGIN ta_IN: Tamil - India *****/
static const char *my_locale_month_names_ta_IN[13] =
{"ஜனவரி","பெப்ரவரி","மார்ச்","ஏப்ரல்","மே","ஜூன்","ஜூலை","ஆகஸ்ட்","செப்டம்பர்","அக்டோபர்","நவம்பர்","டிசம்பர்r", NullS };
static const char *my_locale_ab_month_names_ta_IN[13] =
{"ஜனவரி","பெப்ரவரி","மார்ச்","ஏப்ரல்","மே","ஜூன்","ஜூலை","ஆகஸ்ட்","செப்டம்பர்","அக்டோபர்","நவம்பர்","டிசம்பர்r", NullS };
static const char *my_locale_day_names_ta_IN[8] =
{"திங்கள்","செவ்வாய்","புதன்","வியாழன்","வெள்ளி","சனி","ஞாயிறு", NullS };
static const char *my_locale_ab_day_names_ta_IN[8] =
{"த","ச","ப","வ","வ","ச","ஞ", NullS };
static TYPELIB my_locale_typelib_month_names_ta_IN =
{ array_elements(my_locale_month_names_ta_IN)-1, "", my_locale_month_names_ta_IN, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ta_IN =
{ array_elements(my_locale_ab_month_names_ta_IN)-1, "", my_locale_ab_month_names_ta_IN, NULL };
static TYPELIB my_locale_typelib_day_names_ta_IN =
{ array_elements(my_locale_day_names_ta_IN)-1, "", my_locale_day_names_ta_IN, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ta_IN =
{ array_elements(my_locale_ab_day_names_ta_IN)-1, "", my_locale_ab_day_names_ta_IN, NULL };
MY_LOCALE my_locale_ta_IN
(
49,
"ta_IN",
"Tamil - India",
FALSE,
&my_locale_typelib_month_names_ta_IN,
&my_locale_typelib_ab_month_names_ta_IN,
&my_locale_typelib_day_names_ta_IN,
&my_locale_typelib_ab_day_names_ta_IN,
10,
8
);
/***** LOCALE END ta_IN *****/
/***** LOCALE BEGIN te_IN: Telugu - India *****/
static const char *my_locale_month_names_te_IN[13] =
{"జనవరి","ఫిబ్రవరి","మార్చి","ఏప్రిల్","మే","జూన్","జూలై","ఆగస్టు","సెప్టెంబర్","అక్టోబర్","నవంబర్","డిసెంబర్", NullS };
static const char *my_locale_ab_month_names_te_IN[13] =
{"జనవరి","ఫిబ్రవరి","మార్చి","ఏప్రిల్","మే","జూన్","జూలై","ఆగస్టు","సెప్టెంబర్","అక్టోబర్","నవంబర్","డిసెంబర్", NullS };
static const char *my_locale_day_names_te_IN[8] =
{"సోమవారం","మంగళవారం","బుధవారం","గురువారం","శుక్రవారం","శనివారం","ఆదివారం", NullS };
static const char *my_locale_ab_day_names_te_IN[8] =
{"సోమ","మంగళ","బుధ","గురు","శుక్ర","శని","ఆది", NullS };
static TYPELIB my_locale_typelib_month_names_te_IN =
{ array_elements(my_locale_month_names_te_IN)-1, "", my_locale_month_names_te_IN, NULL };
static TYPELIB my_locale_typelib_ab_month_names_te_IN =
{ array_elements(my_locale_ab_month_names_te_IN)-1, "", my_locale_ab_month_names_te_IN, NULL };
static TYPELIB my_locale_typelib_day_names_te_IN =
{ array_elements(my_locale_day_names_te_IN)-1, "", my_locale_day_names_te_IN, NULL };
static TYPELIB my_locale_typelib_ab_day_names_te_IN =
{ array_elements(my_locale_ab_day_names_te_IN)-1, "", my_locale_ab_day_names_te_IN, NULL };
MY_LOCALE my_locale_te_IN
(
50,
"te_IN",
"Telugu - India",
FALSE,
&my_locale_typelib_month_names_te_IN,
&my_locale_typelib_ab_month_names_te_IN,
&my_locale_typelib_day_names_te_IN,
&my_locale_typelib_ab_day_names_te_IN,
10,
9
);
/***** LOCALE END te_IN *****/
/***** LOCALE BEGIN th_TH: Thai - Thailand *****/
static const char *my_locale_month_names_th_TH[13] =
{"มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม", NullS };
static const char *my_locale_ab_month_names_th_TH[13] =
{"ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.", NullS };
static const char *my_locale_day_names_th_TH[8] =
{"จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์","อาทิตย์", NullS };
static const char *my_locale_ab_day_names_th_TH[8] =
{"จ.","อ.","พ.","พฤ.","ศ.","ส.","อา.", NullS };
static TYPELIB my_locale_typelib_month_names_th_TH =
{ array_elements(my_locale_month_names_th_TH)-1, "", my_locale_month_names_th_TH, NULL };
static TYPELIB my_locale_typelib_ab_month_names_th_TH =
{ array_elements(my_locale_ab_month_names_th_TH)-1, "", my_locale_ab_month_names_th_TH, NULL };
static TYPELIB my_locale_typelib_day_names_th_TH =
{ array_elements(my_locale_day_names_th_TH)-1, "", my_locale_day_names_th_TH, NULL };
static TYPELIB my_locale_typelib_ab_day_names_th_TH =
{ array_elements(my_locale_ab_day_names_th_TH)-1, "", my_locale_ab_day_names_th_TH, NULL };
MY_LOCALE my_locale_th_TH
(
51,
"th_TH",
"Thai - Thailand",
FALSE,
&my_locale_typelib_month_names_th_TH,
&my_locale_typelib_ab_month_names_th_TH,
&my_locale_typelib_day_names_th_TH,
&my_locale_typelib_ab_day_names_th_TH,
10,
8
);
/***** LOCALE END th_TH *****/
/***** LOCALE BEGIN tr_TR: Turkish - Turkey *****/
static const char *my_locale_month_names_tr_TR[13] =
{"Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık", NullS };
static const char *my_locale_ab_month_names_tr_TR[13] =
{"Oca","Şub","Mar","Nis","May","Haz","Tem","Ağu","Eyl","Eki","Kas","Ara", NullS };
static const char *my_locale_day_names_tr_TR[8] =
{"Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi","Pazar", NullS };
static const char *my_locale_ab_day_names_tr_TR[8] =
{"Pzt","Sal","Çrş","Prş","Cum","Cts","Paz", NullS };
static TYPELIB my_locale_typelib_month_names_tr_TR =
{ array_elements(my_locale_month_names_tr_TR)-1, "", my_locale_month_names_tr_TR, NULL };
static TYPELIB my_locale_typelib_ab_month_names_tr_TR =
{ array_elements(my_locale_ab_month_names_tr_TR)-1, "", my_locale_ab_month_names_tr_TR, NULL };
static TYPELIB my_locale_typelib_day_names_tr_TR =
{ array_elements(my_locale_day_names_tr_TR)-1, "", my_locale_day_names_tr_TR, NULL };
static TYPELIB my_locale_typelib_ab_day_names_tr_TR =
{ array_elements(my_locale_ab_day_names_tr_TR)-1, "", my_locale_ab_day_names_tr_TR, NULL };
MY_LOCALE my_locale_tr_TR
(
52,
"tr_TR",
"Turkish - Turkey",
FALSE,
&my_locale_typelib_month_names_tr_TR,
&my_locale_typelib_ab_month_names_tr_TR,
&my_locale_typelib_day_names_tr_TR,
&my_locale_typelib_ab_day_names_tr_TR,
7,
9
);
/***** LOCALE END tr_TR *****/
/***** LOCALE BEGIN uk_UA: Ukrainian - Ukraine *****/
static const char *my_locale_month_names_uk_UA[13] =
{"Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень", NullS };
static const char *my_locale_ab_month_names_uk_UA[13] =
{"Січ","Лют","Бер","Кві","Тра","Чер","Лип","Сер","Вер","Жов","Лис","Гру", NullS };
static const char *my_locale_day_names_uk_UA[8] =
{"Понеділок","Вівторок","Середа","Четвер","П'ятниця","Субота","Неділя", NullS };
static const char *my_locale_ab_day_names_uk_UA[8] =
{"Пнд","Втр","Срд","Чтв","Птн","Сбт","Ндл", NullS };
static TYPELIB my_locale_typelib_month_names_uk_UA =
{ array_elements(my_locale_month_names_uk_UA)-1, "", my_locale_month_names_uk_UA, NULL };
static TYPELIB my_locale_typelib_ab_month_names_uk_UA =
{ array_elements(my_locale_ab_month_names_uk_UA)-1, "", my_locale_ab_month_names_uk_UA, NULL };
static TYPELIB my_locale_typelib_day_names_uk_UA =
{ array_elements(my_locale_day_names_uk_UA)-1, "", my_locale_day_names_uk_UA, NULL };
static TYPELIB my_locale_typelib_ab_day_names_uk_UA =
{ array_elements(my_locale_ab_day_names_uk_UA)-1, "", my_locale_ab_day_names_uk_UA, NULL };
MY_LOCALE my_locale_uk_UA
(
53,
"uk_UA",
"Ukrainian - Ukraine",
FALSE,
&my_locale_typelib_month_names_uk_UA,
&my_locale_typelib_ab_month_names_uk_UA,
&my_locale_typelib_day_names_uk_UA,
&my_locale_typelib_ab_day_names_uk_UA,
8,
9
);
/***** LOCALE END uk_UA *****/
/***** LOCALE BEGIN ur_PK: Urdu - Pakistan *****/
static const char *my_locale_month_names_ur_PK[13] =
{"جنوري","فروري","مارچ","اپريل","مٓی","جون","جولاي","اگست","ستمبر","اكتوبر","نومبر","دسمبر", NullS };
static const char *my_locale_ab_month_names_ur_PK[13] =
{"جنوري","فروري","مارچ","اپريل","مٓی","جون","جولاي","اگست","ستمبر","اكتوبر","نومبر","دسمبر", NullS };
static const char *my_locale_day_names_ur_PK[8] =
{"پير","منگل","بدھ","جمعرات","جمعه","هفته","اتوار", NullS };
static const char *my_locale_ab_day_names_ur_PK[8] =
{"پير","منگل","بدھ","جمعرات","جمعه","هفته","اتوار", NullS };
static TYPELIB my_locale_typelib_month_names_ur_PK =
{ array_elements(my_locale_month_names_ur_PK)-1, "", my_locale_month_names_ur_PK, NULL };
static TYPELIB my_locale_typelib_ab_month_names_ur_PK =
{ array_elements(my_locale_ab_month_names_ur_PK)-1, "", my_locale_ab_month_names_ur_PK, NULL };
static TYPELIB my_locale_typelib_day_names_ur_PK =
{ array_elements(my_locale_day_names_ur_PK)-1, "", my_locale_day_names_ur_PK, NULL };
static TYPELIB my_locale_typelib_ab_day_names_ur_PK =
{ array_elements(my_locale_ab_day_names_ur_PK)-1, "", my_locale_ab_day_names_ur_PK, NULL };
MY_LOCALE my_locale_ur_PK
(
54,
"ur_PK",
"Urdu - Pakistan",
FALSE,
&my_locale_typelib_month_names_ur_PK,
&my_locale_typelib_ab_month_names_ur_PK,
&my_locale_typelib_day_names_ur_PK,
&my_locale_typelib_ab_day_names_ur_PK,
6,
6
);
/***** LOCALE END ur_PK *****/
/***** LOCALE BEGIN vi_VN: Vietnamese - Vietnam *****/
static const char *my_locale_month_names_vi_VN[13] =
{"Tháng một","Tháng hai","Tháng ba","Tháng tư","Tháng năm","Tháng sáu","Tháng bảy","Tháng tám","Tháng chín","Tháng mười","Tháng mười một","Tháng mười hai", NullS };
static const char *my_locale_ab_month_names_vi_VN[13] =
{"Thg 1","Thg 2","Thg 3","Thg 4","Thg 5","Thg 6","Thg 7","Thg 8","Thg 9","Thg 10","Thg 11","Thg 12", NullS };
static const char *my_locale_day_names_vi_VN[8] =
{"Thứ hai ","Thứ ba ","Thứ tư ","Thứ năm ","Thứ sáu ","Thứ bảy ","Chủ nhật ", NullS };
static const char *my_locale_ab_day_names_vi_VN[8] =
{"Th 2 ","Th 3 ","Th 4 ","Th 5 ","Th 6 ","Th 7 ","CN ", NullS };
static TYPELIB my_locale_typelib_month_names_vi_VN =
{ array_elements(my_locale_month_names_vi_VN)-1, "", my_locale_month_names_vi_VN, NULL };
static TYPELIB my_locale_typelib_ab_month_names_vi_VN =
{ array_elements(my_locale_ab_month_names_vi_VN)-1, "", my_locale_ab_month_names_vi_VN, NULL };
static TYPELIB my_locale_typelib_day_names_vi_VN =
{ array_elements(my_locale_day_names_vi_VN)-1, "", my_locale_day_names_vi_VN, NULL };
static TYPELIB my_locale_typelib_ab_day_names_vi_VN =
{ array_elements(my_locale_ab_day_names_vi_VN)-1, "", my_locale_ab_day_names_vi_VN, NULL };
MY_LOCALE my_locale_vi_VN
(
55,
"vi_VN",
"Vietnamese - Vietnam",
FALSE,
&my_locale_typelib_month_names_vi_VN,
&my_locale_typelib_ab_month_names_vi_VN,
&my_locale_typelib_day_names_vi_VN,
&my_locale_typelib_ab_day_names_vi_VN,
16,
11
);
/***** LOCALE END vi_VN *****/
/***** LOCALE BEGIN zh_CN: Chinese - Peoples Republic of China *****/
static const char *my_locale_month_names_zh_CN[13] =
{"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月", NullS };
static const char *my_locale_ab_month_names_zh_CN[13] =
{" 1月"," 2月"," 3月"," 4月"," 5月"," 6月"," 7月"," 8月"," 9月","10月","11月","12月", NullS };
static const char *my_locale_day_names_zh_CN[8] =
{"星期一","星期二","星期三","星期四","星期五","星期六","星期日", NullS };
static const char *my_locale_ab_day_names_zh_CN[8] =
{"一","二","三","四","五","六","日", NullS };
static TYPELIB my_locale_typelib_month_names_zh_CN =
{ array_elements(my_locale_month_names_zh_CN)-1, "", my_locale_month_names_zh_CN, NULL };
static TYPELIB my_locale_typelib_ab_month_names_zh_CN =
{ array_elements(my_locale_ab_month_names_zh_CN)-1, "", my_locale_ab_month_names_zh_CN, NULL };
static TYPELIB my_locale_typelib_day_names_zh_CN =
{ array_elements(my_locale_day_names_zh_CN)-1, "", my_locale_day_names_zh_CN, NULL };
static TYPELIB my_locale_typelib_ab_day_names_zh_CN =
{ array_elements(my_locale_ab_day_names_zh_CN)-1, "", my_locale_ab_day_names_zh_CN, NULL };
MY_LOCALE my_locale_zh_CN
(
56,
"zh_CN",
"Chinese - Peoples Republic of China",
FALSE,
&my_locale_typelib_month_names_zh_CN,
&my_locale_typelib_ab_month_names_zh_CN,
&my_locale_typelib_day_names_zh_CN,
&my_locale_typelib_ab_day_names_zh_CN,
3,
3
);
/***** LOCALE END zh_CN *****/
/***** LOCALE BEGIN zh_TW: Chinese - Taiwan *****/
static const char *my_locale_month_names_zh_TW[13] =
{"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月", NullS };
static const char *my_locale_ab_month_names_zh_TW[13] =
{" 1月"," 2月"," 3月"," 4月"," 5月"," 6月"," 7月"," 8月"," 9月","10月","11月","12月", NullS };
static const char *my_locale_day_names_zh_TW[8] =
{"週一","週二","週三","週四","週五","週六","週日", NullS };
static const char *my_locale_ab_day_names_zh_TW[8] =
{"一","二","三","四","五","六","日", NullS };
static TYPELIB my_locale_typelib_month_names_zh_TW =
{ array_elements(my_locale_month_names_zh_TW)-1, "", my_locale_month_names_zh_TW, NULL };
static TYPELIB my_locale_typelib_ab_month_names_zh_TW =
{ array_elements(my_locale_ab_month_names_zh_TW)-1, "", my_locale_ab_month_names_zh_TW, NULL };
static TYPELIB my_locale_typelib_day_names_zh_TW =
{ array_elements(my_locale_day_names_zh_TW)-1, "", my_locale_day_names_zh_TW, NULL };
static TYPELIB my_locale_typelib_ab_day_names_zh_TW =
{ array_elements(my_locale_ab_day_names_zh_TW)-1, "", my_locale_ab_day_names_zh_TW, NULL };
MY_LOCALE my_locale_zh_TW
(
57,
"zh_TW",
"Chinese - Taiwan",
FALSE,
&my_locale_typelib_month_names_zh_TW,
&my_locale_typelib_ab_month_names_zh_TW,
&my_locale_typelib_day_names_zh_TW,
&my_locale_typelib_ab_day_names_zh_TW,
3,
2
);
/***** LOCALE END zh_TW *****/
/***** LOCALE BEGIN ar_DZ: Arabic - Algeria *****/
MY_LOCALE my_locale_ar_DZ
(
58,
"ar_DZ",
"Arabic - Algeria",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_DZ *****/
/***** LOCALE BEGIN ar_EG: Arabic - Egypt *****/
MY_LOCALE my_locale_ar_EG
(
59,
"ar_EG",
"Arabic - Egypt",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_EG *****/
/***** LOCALE BEGIN ar_IN: Arabic - Iran *****/
MY_LOCALE my_locale_ar_IN
(
60,
"ar_IN",
"Arabic - Iran",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_IN *****/
/***** LOCALE BEGIN ar_IQ: Arabic - Iraq *****/
MY_LOCALE my_locale_ar_IQ
(
61,
"ar_IQ",
"Arabic - Iraq",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_IQ *****/
/***** LOCALE BEGIN ar_KW: Arabic - Kuwait *****/
MY_LOCALE my_locale_ar_KW
(
62,
"ar_KW",
"Arabic - Kuwait",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_KW *****/
/***** LOCALE BEGIN ar_LB: Arabic - Lebanon *****/
MY_LOCALE my_locale_ar_LB
(
63,
"ar_LB",
"Arabic - Lebanon",
FALSE,
&my_locale_typelib_month_names_ar_JO,
&my_locale_typelib_ab_month_names_ar_JO,
&my_locale_typelib_day_names_ar_JO,
&my_locale_typelib_ab_day_names_ar_JO,
12,
8
);
/***** LOCALE END ar_LB *****/
/***** LOCALE BEGIN ar_LY: Arabic - Libya *****/
MY_LOCALE my_locale_ar_LY
(
64,
"ar_LY",
"Arabic - Libya",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_LY *****/
/***** LOCALE BEGIN ar_MA: Arabic - Morocco *****/
MY_LOCALE my_locale_ar_MA
(
65,
"ar_MA",
"Arabic - Morocco",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_MA *****/
/***** LOCALE BEGIN ar_OM: Arabic - Oman *****/
MY_LOCALE my_locale_ar_OM
(
66,
"ar_OM",
"Arabic - Oman",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_OM *****/
/***** LOCALE BEGIN ar_QA: Arabic - Qatar *****/
MY_LOCALE my_locale_ar_QA
(
67,
"ar_QA",
"Arabic - Qatar",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_QA *****/
/***** LOCALE BEGIN ar_SD: Arabic - Sudan *****/
MY_LOCALE my_locale_ar_SD
(
68,
"ar_SD",
"Arabic - Sudan",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_SD *****/
/***** LOCALE BEGIN ar_TN: Arabic - Tunisia *****/
MY_LOCALE my_locale_ar_TN
(
69,
"ar_TN",
"Arabic - Tunisia",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_TN *****/
/***** LOCALE BEGIN ar_YE: Arabic - Yemen *****/
MY_LOCALE my_locale_ar_YE
(
70,
"ar_YE",
"Arabic - Yemen",
FALSE,
&my_locale_typelib_month_names_ar_BH,
&my_locale_typelib_ab_month_names_ar_BH,
&my_locale_typelib_day_names_ar_BH,
&my_locale_typelib_ab_day_names_ar_BH,
6,
8
);
/***** LOCALE END ar_YE *****/
/***** LOCALE BEGIN de_BE: German - Belgium *****/
MY_LOCALE my_locale_de_BE
(
71,
"de_BE",
"German - Belgium",
FALSE,
&my_locale_typelib_month_names_de_DE,
&my_locale_typelib_ab_month_names_de_DE,
&my_locale_typelib_day_names_de_DE,
&my_locale_typelib_ab_day_names_de_DE,
9,
10
);
/***** LOCALE END de_BE *****/
/***** LOCALE BEGIN de_CH: German - Switzerland *****/
MY_LOCALE my_locale_de_CH
(
72,
"de_CH",
"German - Switzerland",
FALSE,
&my_locale_typelib_month_names_de_DE,
&my_locale_typelib_ab_month_names_de_DE,
&my_locale_typelib_day_names_de_DE,
&my_locale_typelib_ab_day_names_de_DE,
9,
10
);
/***** LOCALE END de_CH *****/
/***** LOCALE BEGIN de_LU: German - Luxembourg *****/
MY_LOCALE my_locale_de_LU
(
73,
"de_LU",
"German - Luxembourg",
FALSE,
&my_locale_typelib_month_names_de_DE,
&my_locale_typelib_ab_month_names_de_DE,
&my_locale_typelib_day_names_de_DE,
&my_locale_typelib_ab_day_names_de_DE,
9,
10
);
/***** LOCALE END de_LU *****/
/***** LOCALE BEGIN en_AU: English - Australia *****/
MY_LOCALE my_locale_en_AU
(
74,
"en_AU",
"English - Australia",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_AU *****/
/***** LOCALE BEGIN en_CA: English - Canada *****/
MY_LOCALE my_locale_en_CA
(
75,
"en_CA",
"English - Canada",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_CA *****/
/***** LOCALE BEGIN en_GB: English - United Kingdom *****/
MY_LOCALE my_locale_en_GB
(
1,
"en_GB",
"English - United Kingdom",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_GB *****/
/***** LOCALE BEGIN en_IN: English - India *****/
MY_LOCALE my_locale_en_IN
(
76,
"en_IN",
"English - India",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_IN *****/
/***** LOCALE BEGIN en_NZ: English - New Zealand *****/
MY_LOCALE my_locale_en_NZ
(
77,
"en_NZ",
"English - New Zealand",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_NZ *****/
/***** LOCALE BEGIN en_PH: English - Philippines *****/
MY_LOCALE my_locale_en_PH
(
78,
"en_PH",
"English - Philippines",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_PH *****/
/***** LOCALE BEGIN en_ZA: English - South Africa *****/
MY_LOCALE my_locale_en_ZA
(
79,
"en_ZA",
"English - South Africa",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_ZA *****/
/***** LOCALE BEGIN en_ZW: English - Zimbabwe *****/
MY_LOCALE my_locale_en_ZW
(
80,
"en_ZW",
"English - Zimbabwe",
TRUE,
&my_locale_typelib_month_names_en_US,
&my_locale_typelib_ab_month_names_en_US,
&my_locale_typelib_day_names_en_US,
&my_locale_typelib_ab_day_names_en_US,
9,
9
);
/***** LOCALE END en_ZW *****/
/***** LOCALE BEGIN es_AR: Spanish - Argentina *****/
MY_LOCALE my_locale_es_AR
(
81,
"es_AR",
"Spanish - Argentina",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_AR *****/
/***** LOCALE BEGIN es_BO: Spanish - Bolivia *****/
MY_LOCALE my_locale_es_BO
(
82,
"es_BO",
"Spanish - Bolivia",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_BO *****/
/***** LOCALE BEGIN es_CL: Spanish - Chile *****/
MY_LOCALE my_locale_es_CL
(
83,
"es_CL",
"Spanish - Chile",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_CL *****/
/***** LOCALE BEGIN es_CO: Spanish - Columbia *****/
MY_LOCALE my_locale_es_CO
(
84,
"es_CO",
"Spanish - Columbia",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_CO *****/
/***** LOCALE BEGIN es_CR: Spanish - Costa Rica *****/
MY_LOCALE my_locale_es_CR
(
85,
"es_CR",
"Spanish - Costa Rica",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_CR *****/
/***** LOCALE BEGIN es_DO: Spanish - Dominican Republic *****/
MY_LOCALE my_locale_es_DO
(
86,
"es_DO",
"Spanish - Dominican Republic",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_DO *****/
/***** LOCALE BEGIN es_EC: Spanish - Ecuador *****/
MY_LOCALE my_locale_es_EC
(
87,
"es_EC",
"Spanish - Ecuador",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_EC *****/
/***** LOCALE BEGIN es_GT: Spanish - Guatemala *****/
MY_LOCALE my_locale_es_GT
(
88,
"es_GT",
"Spanish - Guatemala",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_GT *****/
/***** LOCALE BEGIN es_HN: Spanish - Honduras *****/
MY_LOCALE my_locale_es_HN
(
89,
"es_HN",
"Spanish - Honduras",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_HN *****/
/***** LOCALE BEGIN es_MX: Spanish - Mexico *****/
MY_LOCALE my_locale_es_MX
(
90,
"es_MX",
"Spanish - Mexico",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_MX *****/
/***** LOCALE BEGIN es_NI: Spanish - Nicaragua *****/
MY_LOCALE my_locale_es_NI
(
91,
"es_NI",
"Spanish - Nicaragua",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_NI *****/
/***** LOCALE BEGIN es_PA: Spanish - Panama *****/
MY_LOCALE my_locale_es_PA
(
92,
"es_PA",
"Spanish - Panama",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_PA *****/
/***** LOCALE BEGIN es_PE: Spanish - Peru *****/
MY_LOCALE my_locale_es_PE
(
93,
"es_PE",
"Spanish - Peru",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_PE *****/
/***** LOCALE BEGIN es_PR: Spanish - Puerto Rico *****/
MY_LOCALE my_locale_es_PR
(
94,
"es_PR",
"Spanish - Puerto Rico",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_PR *****/
/***** LOCALE BEGIN es_PY: Spanish - Paraguay *****/
MY_LOCALE my_locale_es_PY
(
95,
"es_PY",
"Spanish - Paraguay",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_PY *****/
/***** LOCALE BEGIN es_SV: Spanish - El Salvador *****/
MY_LOCALE my_locale_es_SV
(
96,
"es_SV",
"Spanish - El Salvador",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_SV *****/
/***** LOCALE BEGIN es_US: Spanish - United States *****/
MY_LOCALE my_locale_es_US
(
97,
"es_US",
"Spanish - United States",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_US *****/
/***** LOCALE BEGIN es_UY: Spanish - Uruguay *****/
MY_LOCALE my_locale_es_UY
(
98,
"es_UY",
"Spanish - Uruguay",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_UY *****/
/***** LOCALE BEGIN es_VE: Spanish - Venezuela *****/
MY_LOCALE my_locale_es_VE
(
99,
"es_VE",
"Spanish - Venezuela",
FALSE,
&my_locale_typelib_month_names_es_ES,
&my_locale_typelib_ab_month_names_es_ES,
&my_locale_typelib_day_names_es_ES,
&my_locale_typelib_ab_day_names_es_ES,
10,
9
);
/***** LOCALE END es_VE *****/
/***** LOCALE BEGIN fr_BE: French - Belgium *****/
MY_LOCALE my_locale_fr_BE
(
100,
"fr_BE",
"French - Belgium",
FALSE,
&my_locale_typelib_month_names_fr_FR,
&my_locale_typelib_ab_month_names_fr_FR,
&my_locale_typelib_day_names_fr_FR,
&my_locale_typelib_ab_day_names_fr_FR,
9,
8
);
/***** LOCALE END fr_BE *****/
/***** LOCALE BEGIN fr_CA: French - Canada *****/
MY_LOCALE my_locale_fr_CA
(
101,
"fr_CA",
"French - Canada",
FALSE,
&my_locale_typelib_month_names_fr_FR,
&my_locale_typelib_ab_month_names_fr_FR,
&my_locale_typelib_day_names_fr_FR,
&my_locale_typelib_ab_day_names_fr_FR,
9,
8
);
/***** LOCALE END fr_CA *****/
/***** LOCALE BEGIN fr_CH: French - Switzerland *****/
MY_LOCALE my_locale_fr_CH
(
102,
"fr_CH",
"French - Switzerland",
FALSE,
&my_locale_typelib_month_names_fr_FR,
&my_locale_typelib_ab_month_names_fr_FR,
&my_locale_typelib_day_names_fr_FR,
&my_locale_typelib_ab_day_names_fr_FR,
9,
8
);
/***** LOCALE END fr_CH *****/
/***** LOCALE BEGIN fr_LU: French - Luxembourg *****/
MY_LOCALE my_locale_fr_LU
(
103,
"fr_LU",
"French - Luxembourg",
FALSE,
&my_locale_typelib_month_names_fr_FR,
&my_locale_typelib_ab_month_names_fr_FR,
&my_locale_typelib_day_names_fr_FR,
&my_locale_typelib_ab_day_names_fr_FR,
9,
8
);
/***** LOCALE END fr_LU *****/
/***** LOCALE BEGIN it_IT: Italian - Italy *****/
MY_LOCALE my_locale_it_IT
(
104,
"it_IT",
"Italian - Italy",
FALSE,
&my_locale_typelib_month_names_it_CH,
&my_locale_typelib_ab_month_names_it_CH,
&my_locale_typelib_day_names_it_CH,
&my_locale_typelib_ab_day_names_it_CH,
9,
9
);
/***** LOCALE END it_IT *****/
/***** LOCALE BEGIN nl_BE: Dutch - Belgium *****/
MY_LOCALE my_locale_nl_BE
(
105,
"nl_BE",
"Dutch - Belgium",
TRUE,
&my_locale_typelib_month_names_nl_NL,
&my_locale_typelib_ab_month_names_nl_NL,
&my_locale_typelib_day_names_nl_NL,
&my_locale_typelib_ab_day_names_nl_NL,
9,
9
);
/***** LOCALE END nl_BE *****/
/***** LOCALE BEGIN no_NO: Norwegian - Norway *****/
MY_LOCALE my_locale_no_NO
(
106,
"no_NO",
"Norwegian - Norway",
FALSE,
&my_locale_typelib_month_names_nb_NO,
&my_locale_typelib_ab_month_names_nb_NO,
&my_locale_typelib_day_names_nb_NO,
&my_locale_typelib_ab_day_names_nb_NO,
9,
7
);
/***** LOCALE END no_NO *****/
/***** LOCALE BEGIN sv_FI: Swedish - Finland *****/
MY_LOCALE my_locale_sv_FI
(
107,
"sv_FI",
"Swedish - Finland",
FALSE,
&my_locale_typelib_month_names_sv_SE,
&my_locale_typelib_ab_month_names_sv_SE,
&my_locale_typelib_day_names_sv_SE,
&my_locale_typelib_ab_day_names_sv_SE,
9,
7
);
/***** LOCALE END sv_FI *****/
/***** LOCALE BEGIN zh_HK: Chinese - Hong Kong SAR *****/
MY_LOCALE my_locale_zh_HK
(
108,
"zh_HK",
"Chinese - Hong Kong SAR",
FALSE,
&my_locale_typelib_month_names_zh_CN,
&my_locale_typelib_ab_month_names_zh_CN,
&my_locale_typelib_day_names_zh_CN,
&my_locale_typelib_ab_day_names_zh_CN,
3,
3
);
/***** LOCALE END zh_HK *****/
/*
The list of all locales.
Note, locales must be ordered according to their
numbers to make my_locale_by_number() work fast.
Some debug asserts below check this.
*/
MY_LOCALE *my_locales[]=
{
&my_locale_en_US,
&my_locale_en_GB,
&my_locale_ja_JP,
&my_locale_sv_SE,
&my_locale_de_DE,
&my_locale_fr_FR,
&my_locale_ar_AE,
&my_locale_ar_BH,
&my_locale_ar_JO,
&my_locale_ar_SA,
&my_locale_ar_SY,
&my_locale_be_BY,
&my_locale_bg_BG,
&my_locale_ca_ES,
&my_locale_cs_CZ,
&my_locale_da_DK,
&my_locale_de_AT,
&my_locale_es_ES,
&my_locale_et_EE,
&my_locale_eu_ES,
&my_locale_fi_FI,
&my_locale_fo_FO,
&my_locale_gl_ES,
&my_locale_gu_IN,
&my_locale_he_IL,
&my_locale_hi_IN,
&my_locale_hr_HR,
&my_locale_hu_HU,
&my_locale_id_ID,
&my_locale_is_IS,
&my_locale_it_CH,
&my_locale_ko_KR,
&my_locale_lt_LT,
&my_locale_lv_LV,
&my_locale_mk_MK,
&my_locale_mn_MN,
&my_locale_ms_MY,
&my_locale_nb_NO,
&my_locale_nl_NL,
&my_locale_pl_PL,
&my_locale_pt_BR,
&my_locale_pt_PT,
&my_locale_ro_RO,
&my_locale_ru_RU,
&my_locale_ru_UA,
&my_locale_sk_SK,
&my_locale_sl_SI,
&my_locale_sq_AL,
&my_locale_sr_YU,
&my_locale_ta_IN,
&my_locale_te_IN,
&my_locale_th_TH,
&my_locale_tr_TR,
&my_locale_uk_UA,
&my_locale_ur_PK,
&my_locale_vi_VN,
&my_locale_zh_CN,
&my_locale_zh_TW,
&my_locale_ar_DZ,
&my_locale_ar_EG,
&my_locale_ar_IN,
&my_locale_ar_IQ,
&my_locale_ar_KW,
&my_locale_ar_LB,
&my_locale_ar_LY,
&my_locale_ar_MA,
&my_locale_ar_OM,
&my_locale_ar_QA,
&my_locale_ar_SD,
&my_locale_ar_TN,
&my_locale_ar_YE,
&my_locale_de_BE,
&my_locale_de_CH,
&my_locale_de_LU,
&my_locale_en_AU,
&my_locale_en_CA,
&my_locale_en_IN,
&my_locale_en_NZ,
&my_locale_en_PH,
&my_locale_en_ZA,
&my_locale_en_ZW,
&my_locale_es_AR,
&my_locale_es_BO,
&my_locale_es_CL,
&my_locale_es_CO,
&my_locale_es_CR,
&my_locale_es_DO,
&my_locale_es_EC,
&my_locale_es_GT,
&my_locale_es_HN,
&my_locale_es_MX,
&my_locale_es_NI,
&my_locale_es_PA,
&my_locale_es_PE,
&my_locale_es_PR,
&my_locale_es_PY,
&my_locale_es_SV,
&my_locale_es_US,
&my_locale_es_UY,
&my_locale_es_VE,
&my_locale_fr_BE,
&my_locale_fr_CA,
&my_locale_fr_CH,
&my_locale_fr_LU,
&my_locale_it_IT,
&my_locale_nl_BE,
&my_locale_no_NO,
&my_locale_sv_FI,
&my_locale_zh_HK,
NULL
};
MY_LOCALE *my_locale_by_number(uint number)
{
MY_LOCALE *locale;
if (number >= array_elements(my_locales) - 1)
return NULL;
locale= my_locales[number];
// Check that locale is on its correct position in the array
DBUG_ASSERT(locale == my_locales[locale->number]);
return locale;
}
MY_LOCALE *my_locale_by_name(const char *name)
{
MY_LOCALE **locale;
for (locale= my_locales; *locale != NULL; locale++)
{
if (!my_strcasecmp(&my_charset_latin1, (*locale)->name, name))
{
// Check that locale is on its correct position in the array
DBUG_ASSERT((*locale) == my_locales[(*locale)->number]);
return *locale;
}
}
return NULL;
}
|
liyu1981/mysql51-hack
|
sql/sql_locale.cc
|
C++
|
gpl-2.0
| 111,497 |
/*****************************************************************************
* osdep.c: platform-specific code
*****************************************************************************
* Copyright (C) 2003-2014 x264 project
*
* Authors: Steven Walters <[email protected]>
* Laurent Aimar <[email protected]>
* Henrik Gramner <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at [email protected].
*****************************************************************************/
#include "common.h"
#ifdef _WIN32
#include <windows.h>
#include <io.h>
#endif
#if SYS_WINDOWS
#include <sys/types.h>
#include <sys/timeb.h>
#else
#include <sys/time.h>
#endif
#include <time.h>
#if PTW32_STATIC_LIB
/* this is a global in pthread-win32 to indicate if it has been initialized or not */
extern int ptw32_processInitialized;
#endif
int64_t x264_mdate( void )
{
#if SYS_WINDOWS
struct timeb tb;
ftime( &tb );
return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000;
#else
struct timeval tv_date;
gettimeofday( &tv_date, NULL );
return (int64_t)tv_date.tv_sec * 1000000 + (int64_t)tv_date.tv_usec;
#endif
}
#if HAVE_WIN32THREAD || PTW32_STATIC_LIB
/* state of the threading library being initialized */
static volatile LONG x264_threading_is_init = 0;
static void x264_threading_destroy( void )
{
#if PTW32_STATIC_LIB
pthread_win32_thread_detach_np();
pthread_win32_process_detach_np();
#else
x264_win32_threading_destroy();
#endif
}
int x264_threading_init( void )
{
/* if already init, then do nothing */
if( InterlockedCompareExchange( &x264_threading_is_init, 1, 0 ) )
return 0;
#if PTW32_STATIC_LIB
/* if static pthread-win32 is already initialized, then do nothing */
if( ptw32_processInitialized )
return 0;
if( !pthread_win32_process_attach_np() )
return -1;
#else
if( x264_win32_threading_init() )
return -1;
#endif
/* register cleanup to run at process termination */
atexit( x264_threading_destroy );
return 0;
}
#endif
#if HAVE_MMX
#ifdef __INTEL_COMPILER
/* Agner's patch to Intel's CPU dispatcher from pages 131-132 of
* http://agner.org/optimize/optimizing_cpp.pdf (2011-01-30)
* adapted to x264's cpu schema. */
// Global variable indicating cpu
int __intel_cpu_indicator = 0;
// CPU dispatcher function
void x264_intel_cpu_indicator_init( void )
{
unsigned int cpu = x264_cpu_detect();
if( cpu&X264_CPU_AVX )
__intel_cpu_indicator = 0x20000;
else if( cpu&X264_CPU_SSE42 )
__intel_cpu_indicator = 0x8000;
else if( cpu&X264_CPU_SSE4 )
__intel_cpu_indicator = 0x2000;
else if( cpu&X264_CPU_SSSE3 )
__intel_cpu_indicator = 0x1000;
else if( cpu&X264_CPU_SSE3 )
__intel_cpu_indicator = 0x800;
else if( cpu&X264_CPU_SSE2 && !(cpu&X264_CPU_SSE2_IS_SLOW) )
__intel_cpu_indicator = 0x200;
else if( cpu&X264_CPU_SSE )
__intel_cpu_indicator = 0x80;
else if( cpu&X264_CPU_MMX2 )
__intel_cpu_indicator = 8;
else
__intel_cpu_indicator = 1;
}
/* __intel_cpu_indicator_init appears to have a non-standard calling convention that
* assumes certain registers aren't preserved, so we'll route it through a function
* that backs up all the registers. */
void __intel_cpu_indicator_init( void )
{
x264_safe_intel_cpu_indicator_init();
}
#else
void x264_intel_cpu_indicator_init( void )
{}
#endif
#endif
#ifdef _WIN32
/* Functions for dealing with Unicode on Windows. */
FILE *x264_fopen( const char *filename, const char *mode )
{
wchar_t filename_utf16[MAX_PATH * 2];
wchar_t mode_utf16[16];
if( utf8_to_utf16( filename, filename_utf16 ) && utf8_to_utf16( mode, mode_utf16 ) )
return _wfopen( filename_utf16, mode_utf16 );
return NULL;
}
int x264_rename( const char *oldname, const char *newname )
{
wchar_t oldname_utf16[MAX_PATH * 2];
wchar_t newname_utf16[MAX_PATH * 2];
if( utf8_to_utf16( oldname, oldname_utf16 ) && utf8_to_utf16( newname, newname_utf16 ) )
{
/* POSIX says that rename() removes the destination, but Win32 doesn't. */
_wunlink( newname_utf16 );
return _wrename( oldname_utf16, newname_utf16 );
}
return -1;
}
int x264_stat( const char *path, x264_struct_stat *buf )
{
wchar_t path_utf16[MAX_PATH * 2];
if( utf8_to_utf16( path, path_utf16 ) )
return _wstati64( path_utf16, buf );
return -1;
}
int x264_vfprintf( FILE *stream, const char *format, va_list arg )
{
HANDLE console = NULL;
DWORD mode;
if( stream == stdout )
console = GetStdHandle( STD_OUTPUT_HANDLE );
else if( stream == stderr )
console = GetStdHandle( STD_ERROR_HANDLE );
/* Only attempt to convert to UTF-16 when writing to a non-redirected console screen buffer. */
if( GetConsoleMode( console, &mode ) )
{
char buf[4096];
wchar_t buf_utf16[4096];
int length = vsnprintf( buf, sizeof(buf), format, arg );
if( length > 0 && length < sizeof(buf) )
{
/* WriteConsoleW is the most reliable way to output Unicode to a console. */
int length_utf16 = MultiByteToWideChar( CP_UTF8, 0, buf, length, buf_utf16, sizeof(buf_utf16)/sizeof(wchar_t) );
DWORD written;
WriteConsoleW( console, buf_utf16, length_utf16, &written, NULL );
return length;
}
}
return vfprintf( stream, format, arg );
}
int x264_is_pipe( const char *path )
{
wchar_t path_utf16[MAX_PATH];
if( utf8_to_utf16( path, path_utf16 ) )
return WaitNamedPipeW( path_utf16, 0 );
return 0;
}
#endif
|
jpsdr/x264_tMod
|
common/osdep.c
|
C
|
gpl-2.0
| 6,475 |
/* Generated By:JJTree: Do not edit this line. .\MiniSqlTreeConstants.java */
package parser;
public interface MiniSqlTreeConstants
{
public int JJT_START = 0;
public int JJTVOID = 1;
public int JJT_CREATETABLE = 2;
public int JJT_CREATEINDEX = 3;
public int JJT_DROPTABLE = 4;
public int JJT_DROPINDEX = 5;
public int JJT_DESCRIBE = 6;
public int JJT_INSERT = 7;
public int JJT_SELECT = 8;
public int JJT_UPDATE = 9;
public int JJT_DELETE = 10;
public int JJT_IDENTLIST = 11;
public int JJT_COLUMNTYPE = 12;
public int JJT_ORDERBY = 13;
public int JJT_OREXPR = 14;
public int JJT_ANDEXPR = 15;
public int JJT_EXPRPRED = 16;
public int JJT_EXPRVALUE = 17;
public String[] jjtNodeName = {
"_Start",
"void",
"_CreateTable",
"_CreateIndex",
"_DropTable",
"_DropIndex",
"_Describe",
"_Insert",
"_Select",
"_Update",
"_Delete",
"_IdentList",
"_ColumnType",
"_OrderBy",
"_OrExpr",
"_AndExpr",
"_ExprPred",
"_ExprValue",
};
}
|
wang159/CS541
|
project_4/yu/src/parser/MiniSqlTreeConstants.java
|
Java
|
gpl-2.0
| 1,082 |
/* ContainerEvent.java -- components added/removed from a container
Copyright (C) 1999, 2002, 2005 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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 java.awt.event;
import java.awt.Component;
import java.awt.Container;
/**
* This event is generated when a component is added or removed from a
* container. Applications do not ordinarily need to handle these events
* since the AWT system handles them internally.
*
* @author Aaron M. Renn ([email protected])
* @see ContainerAdapter
* @see ContainerListener
* @since 1.1
* @status updated to 1.4
*/
public class ContainerEvent extends ComponentEvent
{
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -4114942250539772041L;
/** This is the first id in the id range used by this class. */
public static final int CONTAINER_FIRST = 300;
/** This is the last id in the id range used by this class. */
public static final int CONTAINER_LAST = 301;
/** This id indicates a component was added to the container. */
public static final int COMPONENT_ADDED = 300;
/** This id indicates a component was removed from the container. */
public static final int COMPONENT_REMOVED = 301;
/**
* The non-null child component that was added or removed.
*
* @serial the child component that changed
*/
private final Component child;
/**
* Initializes a new instance of <code>ContainerEvent</code> with the
* specified source and id. Additionally, the affected child component
* is also passed as a parameter. Note that an invalid id leads to
* unspecified results.
*
* @param source the source container of the event
* @param id the event id
* @param child the child component affected by this event
* @throws IllegalArgumentException if source is null
*/
public ContainerEvent(Component source, int id, Component child)
{
super(source, id);
this.child = child;
}
/**
* Returns the source of this event as a <code>Container</code>.
*
* @return the source of the event
* @throws ClassCastException if the source is changed to a non-Container
*/
public Container getContainer()
{
return (Container) source;
}
/**
* This method returns the child object that was added or removed from
* the container.
*
* @return the child object added or removed
*/
public Component getChild()
{
return child;
}
/**
* This method returns a string identifying this event. It is formatted as:
* <code>(getID() == COMPONENT_ADDED ? "COMPONENT_ADDED"
* : "COMPONENT_REMOVED") + ",child=" + getChild().getName()</code>.
*
* @return a string identifying this event
*/
public String paramString()
{
// Unlike Sun, we don't throw NullPointerException if child is illegally
// null.
return (id == COMPONENT_ADDED ? "COMPONENT_ADDED,child="
: id == COMPONENT_REMOVED ? "COMPONENT_REMOVED,child="
: "unknown type,child=") + (child == null ? "" : child.getName());
}
} // class ContainerEvent
|
unofficial-opensource-apple/gcc_40
|
libjava/java/awt/event/ContainerEvent.java
|
Java
|
gpl-2.0
| 4,702 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.